google-analytics-mcp
AGENTS.md244 starsChanged 43 days agoMITView on GitHub
For AI Agents (Claude Code, Cursor, Codex, Gemini, Antigravity, OpenCode, Aider) connecting to or executing google-analytics-mcp. In 90% of cases, you just need to install and configure this MCP server for your user: A production MCP server for Google Analytics 4 (GA4). It gives you direct access to the Google Analytics Data API v1beta and Admin API v1alpha. If credentials are not yet configured, do not fail or dump a raw Python traceback on the human. Guide them with these…
- Pipes a download into a shell
We split this AGENTS.md into the rules it gives an agent
4 rules. About 1 is common, 0 are distinctive, and 3 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 53
If credentials are not yet configured, do not fail or dump a raw Python traceback on the human.
- Very specific: line 64
If Auth Fails: Call get_troubleshooting_guide(topic="setup") or get_troubleshooting_guide(topic="iam") to guide the human through …
- Very specific: line 75
Do NOT mix incompatible scopes (e.g., User-scoped dimensions with Hit/Item-scoped metrics).
- Very specific: line 85
When your human user asks high-level business questions, call search_skills("<topic>") before constructing queries:
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — Agent Operating Manual
For AI Agents (Claude Code, Cursor, Codex, Gemini, Antigravity, OpenCode, Aider) connecting to or executing
google-analytics-mcp.
⚡ 1. Fast Install & Client Wiring (Start Here)
In 90% of cases, you just need to install and configure this MCP server for your user:
# 1-Line Universal Auto-Installer (Configures Claude Code, Cursor, Claude Desktop & Antigravity)
curl -fsSL "https://ga4.builditwithai.xyz/install" | bash
# Or launch directly via stdio:
uvx google-analytics-mcp
npx -y google-analytics-mcpClient Config Snippet (mcp.json / claude_desktop_config.json)
{
"mcpServers": {
"google-analytics": {
"command": "uvx",
"args": ["google-analytics-mcp"],
"env": {
"GA4_PROPERTY_ID": "123456789",
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service_account.json"
}
}
}
}📖 2. What This Repo Is
A production MCP server for Google Analytics 4 (GA4). It gives you direct access to the Google Analytics Data API v1beta and Admin API v1alpha.
Primary Tools Available:
get_ga4_data: Run multi-dimensional reports with date ranges, metric totals, and server-side aggregation.list_accounts&list_properties: Discover all GA4 properties the credentials can access.get_property_metadata: Fetch exact dimension/metric schemas and custom event definitions for a property.run_realtime_report: Fetch live active users and 30-minute event streams.search_skills: Access pre-engineered analytical recipes (traffic drops, e-commerce, bot filtering).
👤 3. How to Handle the Human (Auth & Setup)
If credentials are not yet configured, do not fail or dump a raw Python traceback on the human. Guide them with these exact steps:
- Ask for their 9-digit GA4 Property ID:
- "You can find your numeric Property ID in Google Analytics under Admin → Property Settings → Property Details."
- Ask for a Google Cloud Service Account JSON Key:
- The human needs a Service Account with the Viewer role on their GA4 Property in Google Analytics Admin → Property Access Management.
- Once they have the
.jsonfile, set:export GA4_PROPERTY_ID="123456789" export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service_account.json"
- If Auth Fails: Call
get_troubleshooting_guide(topic="setup")orget_troubleshooting_guide(topic="iam")to guide the human through permission repair.
⚠️ 4. Quirks & API Landmines (Zero-Hallucination Rules)
- Field Naming:
- Never use Universal Analytics names (e.g.
ga:sessionsorga:pageviewswill hard-fail). sessionDefaultChannelGroup,pagePath,countryare dimensions.sessions,activeUsers,screenPageViews,eventCountare metrics.
- Never use Universal Analytics names (e.g.
- Scope Compatibility:
- Do NOT mix incompatible scopes (e.g., User-scoped dimensions with Hit/Item-scoped metrics). When in doubt, call
get_property_metadatafirst.
- Do NOT mix incompatible scopes (e.g., User-scoped dimensions with Hit/Item-scoped metrics). When in doubt, call
- Date String Formats:
- Allowed values:
'YYYY-MM-DD','today','yesterday','7daysAgo','30daysAgo','90daysAgo'.
- Allowed values:
- Server-Side Aggregation:
get_ga4_datareturns pre-calculated metric totals. You do not need to do token-heavy arithmetic in your prompt.
🎯 5. Playbooks & Skills (How to Answer User Questions)
When your human user asks high-level business questions, call search_skills("<topic>") before constructing queries:
- "Why did my traffic drop?" → Call
search_skills("traffic-diagnosis") - "Where is our revenue / e-commerce sales coming from?" → Call
search_skills("ecommerce-analysis") - "Are bots skewing our analytics?" → Call
search_skills("bot-traffic-detection") - "How much traffic comes from AI (ChatGPT, Claude, Perplexity)?" → Call
search_skills("ai-referral-analysis") - "Which acquisition channels perform best?" → Call
search_skills("channel-acquisition")
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository21 other files it gives its agents.
- docs/llms-full.txtllms.txt
- docs/llms.txtllms.txt
- llms.txtllms.txt
- ga4-analyticsSkill
- ai-referral-analysisSkill
- attribution-scopeSkill
- bot-traffic-detectionSkill
- channel-acquisitionSkill
- common-metric-namesSkill
- compatible-combinationsSkill
- content-performanceSkill
- custom-dimensionsSkill
- date-rangesSkill
- ecommerce-analysisSkill
- filter-structuresSkill
- ga4-limitationsSkill
- gcp-setupSkill
- geo-device-segmentationSkill
- gcp-setupSkill
- traffic-diagnosisSkill
- ua-to-ga4Skill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

