# google-analytics-mcp

Connect an AI agent to Google Analytics 4 to inspect property schemas and build reports. Useful for traffic, channel, and conversion analysis.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 243
- Author: surendranb
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/surendranb/google-analytics-mcp
- Updated: 2026-10-19
- HTML: https://affpapa.org/en/nevibecode/mcp/google-analytics-mcp

## What it 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.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `GOOGLE_APPLICATION_CREDENTIALS`, `GA4_PROPERTY_ID` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
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 <…> 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>

### Codex

**Platform CLI**
```bash
codex mcp add google-analytics-mcp --env GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> --env GA4_PROPERTY_ID=<GA4_PROPERTY_ID> -- uvx google-analytics-mcp
```
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>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "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>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "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>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e GOOGLE_APPLICATION_CREDENTIALS=<GOOGLE_APPLICATION_CREDENTIALS> -e GA4_PROPERTY_ID=<GA4_PROPERTY_ID> google-analytics-mcp uvx google-analytics-mcp
```
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>

## When to use it
- 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
- 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-diagnosis` guide.

## Similar
- [World Monitor](https://affpapa.org/en/nevibecode/mcp/world-monitor.md) — MCP server · ★ 89408
- [Scrapling MCP Server](https://affpapa.org/en/nevibecode/mcp/scrapling-mcp-server.md) — MCP server · ★ 89433
- [MCP Toolbox for Databases](https://affpapa.org/en/nevibecode/mcp/googleapis-mcp-toolbox-for-databases.md) — MCP server · ★ 16717
- [PostHog MCP Server](https://affpapa.org/en/nevibecode/mcp/posthog-mcp-server.md) — MCP server · ★ 40409
- [dbx](https://affpapa.org/en/nevibecode/mcp/dbx.md) — MCP server · ★ 27669
- [Metabase](https://affpapa.org/en/nevibecode/mcp/metabase.md) — MCP server · ★ 49845

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
