Building an SEO Command Center with Claude Code
SEO data lives in fragmented silos — Google Search Console (GSC), Google Analytics 4 (GA4), Google Ads. Cross-referencing them traditionally means CSV exports, spreadsheet VLOOKUPs, or costly dashboards. An AI coding agent like Claude Code collapses that work: instruct it to write Python that pulls each source into local files, then prompt it in plain language to run complex cross-source analysis — paid-organic keyword gaps, high-impression pages with poor CTR, and more. This guide covers the setup and the highest-value analyses.
Project structure
A strict, predictable folder layout keeps the agent oriented when it reads multiple data sources at once.
seo-project/
├── config.json # Client details + API property IDs
├── fetchers/
│ ├── fetch_gsc.py # Search Console
│ ├── fetch_ga4.py # Google Analytics 4
│ ├── fetch_ads.py # Google Ads search terms
│ └── fetch_ai_visibility.py # AI search / citation data
├── data/
│ ├── gsc/ # Query + page performance JSON
│ ├── ga4/ # Traffic by channel, top pages JSON
│ ├── ads/ # Search terms, spend, conversions JSON
│ └── ai-visibility/ # AI citation data JSON
└── reports/ # Generated markdown analysis
Authenticating to the APIs
GSC and GA4 share a single Google Cloud service account:
- Create a Google Cloud project and enable the Search Console API and the Google Analytics Data API.
- Create a service account under IAM & Admin and download its JSON key.
- Add the service-account email as a Read user on the GSC property and a Viewer on the GA4 property.
Google Ads needs a separate OAuth 2.0 setup plus a developer token:
- Get a developer token from the Google Ads API Center (Tools & Settings → Setup → API Center).
- Create OAuth 2.0 credentials in Google Cloud and do a one-time browser auth to generate a refresh token.
- For agencies on a Manager (MCC) account, one developer token and refresh token cover all sub-accounts — just change the customer ID in config.
No API access? Export the last 90 days of data as CSVs from each UI and drop them in the matching
/data/folder. The agent parses CSV as readily as JSON.
Keep the service-account key and tokens out of any shared prompt or repo — reference them from local files and environment variables only.
Building the fetchers by prompt
You don’t need to write the Python yourself. Describe the job and let the agent generate the script — for example:
“Write a Python script using google-api-python-client to pull the top 1,000 queries from Search Console for the last 90 days, and save the output as JSON.”
It will produce something like the GSC fetcher below, which you then run to populate /data/gsc/:
from google.oauth2 import service_account
from googleapiclient.discovery import build
SCOPES = ['https://www.googleapis.com/auth/webmasters.readonly']
def get_gsc_service():
credentials = service_account.Credentials.from_service_account_file(
'service-account-key.json', scopes=SCOPES
)
return build('searchconsole', 'v1', credentials=credentials)
def fetch_queries(service, site_url, start_date, end_date):
response = service.searchanalytics().query(
siteUrl=site_url,
body={
'startDate': start_date,
'endDate': end_date,
'dimensions': ['query'],
'rowLimit': 1000
}
).execute()
return response.get('rows', [])
Cross-source analyses
With the JSON files populated, the agent can read them together and answer strategic questions.
Paid-organic gap analysis is the highest-value one. Prompt: “Compare the GSC query data against the Google Ads search terms.” The agent categorizes into:
- Wasted ad spend — paying for impressions that get no clicks.
- Cannibalization — spending on ads for terms you already rank top-3 for organically.
- Amplification candidates — strong organic queries with no paid coverage.
- Content gaps — terms visible only through paid ads because no organic ranking exists.
Behavioral cross-referencing — other high-value prompts:
- “Which pages get the most GSC impressions but have low CTR? Cross-reference GA4 traffic for those pages.” → metadata optimization targets.
- “Group GSC queries by topic cluster and show which clusters have the most impressions but the lowest average position.” → content investment priorities.
- “Which GA4 pages have high bounce rates but strong GSC positions?” → content-quality or intent-mismatch issues.
Adding AI-visibility tracking
SERP position no longer captures full visibility — citations inside AI Overviews and assistants like ChatGPT and Perplexity matter for Generative Engine Optimization (GEO). There’s no official Google API for AI Overview citations, so pull this from third-party sources into /data/ai-visibility/. Treat these numbers as directional intelligence, not exact metrics — tools are approximating personalized LLM output.
Common sources:
- Third-party SERP/AI-Overview APIs (e.g. DataForSEO, SerpApi, SearchAPI.io) — return structured SERP data including AI-generated answers and cited URLs on pay-as-you-go or subscription terms. Check current pricing before committing.
- Bing Webmaster Tools — a free first-party source for Copilot citation data; no API, but CSV exports drop straight into the folder for analysis.
Layered alongside GSC and Ads data, this lets the agent surface issues like two of your own posts competing for the same AI Overview citation.
Key takeaways
- An AI coding agent turns fragmented SEO reporting into one prompt-driven command center.
- A strict project structure keeps the agent oriented across multiple data sources.
- You describe the fetchers in plain language; you don’t need to write the Python.
- Paid-organic gap analysis is the standout cross-source win; AI-visibility data extends it toward GEO.
