Overview
TheGoogleSearchConsole class provides integration with Google Search Console (GSC) to fetch keyword rankings, search performance metrics, and identify SEO opportunities.
Installation
Authentication
The module uses Google service account credentials for authentication.Environment Variables
Service Account Setup
- Create a service account in Google Cloud Console
- Download the credentials JSON file
- Add the service account email as a user in Search Console (with at least “Full” permissions)
- Set the credentials path in your environment
Initialization
Site URL (e.g., “https://castos.com”). Defaults to
GSC_SITE_URL environment variable.Path to service account credentials JSON. Defaults to
GSC_CREDENTIALS_PATH environment variable.Methods
get_keyword_positions
Get keyword rankings and performance.Number of days to analyze
Max number of keywords to return
get_quick_wins
Find “quick win” opportunities - keywords ranking 11-20 that are closest to page 1.Number of days to analyze
Minimum position
Maximum position
Minimum impressions threshold
Weight score by commercial intent
Search query
Average position
Total impressions
Total clicks
Commercial intent score (0.1-3.0)
“Transactional”, “Commercial Investigation”, “Informational (Relevant)”, or “Informational (Low Value)”
Calculated opportunity score
“high” or “medium”
get_page_performance
Get search performance for a specific page.Page URL or path
Number of days to analyze
get_low_ctr_pages
Find pages with high impressions but low CTR (need better titles/descriptions).Number of days to analyze
CTR below this is considered low (0.03 = 3%)
Minimum impressions to consider
Filter by path
get_trending_queries
Find queries gaining traction (rising impressions).Recent period to analyze
Previous period to compare against
Minimum impressions in recent period
get_position_changes
Track keyword position changes over time.Recent period
Previous period to compare
Commercial Intent Scoring
The module includes built-in commercial intent scoring (_calculate_commercial_intent) that categorizes keywords:
- High Intent (3.0): Transactional - pricing, buy, vs, alternatives, reviews
- Medium-High Intent (2.0): Commercial investigation - how to, guide, strategies
- Medium Intent (1.0): Informational with potential - what is, features, benefits
- Low Intent (0.1): Pure informational/celebrity - who is, biography, age
data_sources/modules/google_search_console.py:146
Example Usage
Source Code Reference
Location:data_sources/modules/google_search_console.py:16