What You’ll Get
- Impressions and clicks by page
- Average position by keyword
- Click-through rate (CTR) analysis
- Quick win opportunities (keywords ranking 11-20)
- Trending search queries
- Low CTR pages needing meta optimization
- Position change tracking
Prerequisites
- Verified ownership of your website in Google Search Console
- A Google Cloud project (same one used for GA4 is fine)
Setup Instructions
Enable the Google Search Console API
- Go to the Google Cloud Console
- Select the same project you used for GA4 (or create a new one)
- Navigate to APIs & Services > Library
- Search for “Google Search Console API”
- Click on the API and click Enable
Use Existing or Create New Service Account
Option A: Reuse Your GA4 Service Account (Recommended)You can use the same service account created for GA4. Skip to Step 3 and use the same JSON key file.Option B: Create a New Service Account
- In Google Cloud Console, go to APIs & Services > Credentials
- Click Create Credentials and select Service Account
- Fill in the service account details:
- Name:
seo-machine-gsc - Description: “Service account for SEO Machine GSC integration”
- Name:
- Click Create and Continue
- Skip the optional steps and click Done
- Create and download a JSON key (same process as GA4)
Grant Access to Search Console Property
- Go to Google Search Console
- Select your property (website)
- Click Settings in the left sidebar
- Click Users and permissions
- Click Add user
- Enter the service account email (e.g.,
[email protected]) - Select permission level: Full (required for API access, but only provides read access)
- Click Add
Get Your Site URL
Your site URL is the property name in Search Console, typically one of:
https://yoursite.com/(for URL prefix properties)sc-domain:yoursite.com(for domain properties)
Available Methods
TheGoogleSearchConsole class provides these methods:
Get Keyword Positions
Fetch keyword rankings and performance:Get Quick Wins
Find keywords ranking 11-20 (easiest to improve):- Transactional: Keywords like “pricing”, “buy”, “best”, “vs”
- Commercial Investigation: Keywords like “how to”, “guide”, “tutorial”
- Informational (Relevant): Keywords like “what is”, “benefits”
- Informational (Low Value): Celebrity/news queries
Get Page Performance
Analyze search performance for a specific page:Get Low CTR Pages
Find pages with high impressions but low CTR:Get Trending Queries
Find queries gaining traction:Track Position Changes
Monitor keyword position improvements/declines:Data Returned
Keyword data includes:Integration with Performance Agent
The Performance Agent uses GSC data to:- Identify quick win opportunities (position 11-20)
- Find pages with low CTR needing meta optimization
- Track declining keyword positions
- Discover trending queries for new content
Opportunity Scoring Formula
For quick wins, opportunity score is calculated as:- Impressions: Higher = more potential traffic
- Distance from position 10: Closer = easier to improve
- Commercial intent: 0.1 (informational) to 3.0 (transactional)
Troubleshooting
Error: User does not have sufficient permissions
Error: User does not have sufficient permissions
- Verify the service account is added to Search Console with Full permissions
- Make sure you’re using the correct site URL format in
.env - Wait a few minutes after adding the user for changes to propagate
Error: Site not found
Error: Site not found
- Check the
GSC_SITE_URLformat matches exactly what’s in Search Console - Try both formats:
https://yoursite.com/andsc-domain:yoursite.com - Verify the property exists in Search Console
Error: No data returned
Error: No data returned
- Search Console data has a 2-3 day delay
- Try a longer time range (e.g., 30 days instead of 7)
- Verify your site has search traffic for the requested period
Error: Credentials file not found
Error: Credentials file not found
- Verify the path in
GSC_CREDENTIALS_PATHis correct - If reusing GA4 credentials, ensure the path matches:
./credentials/ga4-credentials.json - Check file permissions:
chmod 600 credentials/*.json
Testing Your Integration
Verify GSC is working:Best Practices
- Cache Aggressively: GSC has generous limits but use 24-hour cache for historical data
- Batch Requests: Fetch multiple pages/keywords in one request when possible
- Focus on Quick Wins: Position 11-20 keywords are easiest to improve
- Monitor CTR: Low CTR with high impressions = need better meta tags
- Track Trends: Rising queries indicate emerging opportunities
What’s Next
DataForSEO
Add competitive SERP analysis and keyword research
Performance Agent
Learn how the Performance Agent uses GSC data