google-analytics-mcp — Claude Code MCP server for GA4
Connect an AI agent to Google Analytics 4 to inspect property schemas and build reports. Useful for traffic, channel, and conversion analysis.
claude mcp add google-analytics-mcp -e GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> -e GA4_PROPERTY_ID=<GA4_PROPERTY_ID> -- uvx google-analytics-mcpWhat google-analytics-mcp does
The server queries GA4 using selected dimensions, metrics, and date ranges, then aggregates report totals on the server. It can also list accessible accounts and properties, retrieve property metadata, and expose metric compatibility rules. Setup requires GOOGLE_APPLICATION_CREDENTIALS and GA4_PROPERTY_ID.
Available tools include real-time reports and search over analytical guides for tasks such as diagnosing traffic drops, attribution, and e-commerce analysis. Guides load from GitHub. The package collects diagnostic telemetry about command runs, latency, and error codes; set DO_NOT_TRACK=1 or MCP_TELEMETRY_OPT_OUT=1 to opt out. You need Google credentials and a GA4 property ID to connect.
What it helps with
- build GA4 reports from selected dimensions and metrics
- inspect accessible accounts and properties
- check a property's metric and dimension schema
- investigate a sudden traffic decline with a guided analysis
- separate referrals from ChatGPT, Claude, Perplexity, and Gemini
Example prompts for the agent
- Compare GA4 traffic across channels for the selected date ranges.
- List the dimensions and metrics available for my GA4 property.
- Investigate the traffic drop using the
traffic-diagnosisguide.
How to install google-analytics-mcp
Platform CLI
claude mcp add google-analytics-mcp -e GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> -e GA4_PROPERTY_ID=<GA4_PROPERTY_ID> -- uvx google-analytics-mcpReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from google-analytics-mcp <command>
Platform CLI
codex mcp add google-analytics-mcp --env GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> --env GA4_PROPERTY_ID=<GA4_PROPERTY_ID> -- uvx google-analytics-mcpReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from google-analytics-mcp <command>
Config file
{
"mcpServers": {
"google-analytics-mcp": {
"command": "uvx",
"args": [
"google-analytics-mcp"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "<GOOGLE_APPLICATION_CREDENTIALS>",
"GA4_PROPERTY_ID": "<GA4_PROPERTY_ID>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from google-analytics-mcp <command>
Config file
{
"servers": {
"google-analytics-mcp": {
"type": "stdio",
"command": "uvx",
"args": [
"google-analytics-mcp"
],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "<GOOGLE_APPLICATION_CREDENTIALS>",
"GA4_PROPERTY_ID": "<GA4_PROPERTY_ID>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from google-analytics-mcp <command>
Platform CLI
gemini mcp add -e GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> -e GA4_PROPERTY_ID=<GA4_PROPERTY_ID> google-analytics-mcp uvx google-analytics-mcpReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from google-analytics-mcp <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about google-analytics-mcp
How do I install google-analytics-mcp in Claude Code?
Run `claude mcp add google-analytics-mcp -e GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> -e GA4_PROPERTY_ID=<GA4_PROPERTY_ID> -- uvx google-analytics-mcp`. Replace the placeholders with the credentials file path and GA4 property ID.
What does google-analytics-mcp do?
It connects an agent to GA4 for reporting, property and schema inspection, and analysis with built-in guides.
What do I need to connect it to GA4?
Set GOOGLE_APPLICATION_CREDENTIALS to the credentials file path and GA4_PROPERTY_ID to the property ID.