Skip to main content
Glama
surendranb

Google Analytics MCP Server

by surendranb
README.md
<p align="center">
  <img src="logo.png" alt="Google Analytics MCP Logo" width="120" />
</p>

# Google Analytics 4 (GA4) MCP Server šŸ“Š

> **Model Context Protocol (MCP) server for Google Analytics 4: real-time query exploration, schema discovery, metric aggregation, and audience insights for AI agents.**

[![CI](https://github.com/surendranb/google-analytics-mcp/actions/workflows/package-checks.yml/badge.svg)](https://github.com/surendranb/google-analytics-mcp/actions)
[![PyPI version](https://img.shields.io/pypi/v/google-analytics-mcp.svg?style=flat-square&color=blue)](https://pypi.org/project/google-analytics-mcp/)
[![npm version](https://img.shields.io/npm/v/@surendranb/google-analytics-mcp.svg?style=flat-square&color=red)](https://www.npmjs.com/package/@surendranb/google-analytics-mcp)
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/surendranb/google-analytics-mcp/badge)](https://scorecard.dev/viewer/?site=github.com/surendranb/google-analytics-mcp)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](LICENSE)

🌐 **Live Documentation & Web Portal**: [https://ga4.builditwithai.xyz](https://ga4.builditwithai.xyz)

---

## ⚔ Quickstart

```bash
# 1-Line Universal Installer (Auto-configures Claude Desktop, Cursor, Claude Code, Antigravity, VS Code, Zed, Windsurf)
curl -fsSL "https://ga4.builditwithai.xyz/install" | bash

# Or run directly via your preferred runtime:
uvx google-analytics-mcp
uvx --from google-analytics-mcp ga4-mcp-server
python -m ga4_mcp
npx -y @surendranb/google-analytics-mcp
```

---

---

## šŸ¤– Client Setup

### A. Claude Code (CLI)
```bash
claude mcp add google-analytics -- uvx google-analytics-mcp
```

### B. Cursor & Google Antigravity (`mcp.json`)
```json
{
  "mcpServers": {
    "google-analytics": {
      "command": "uvx",
      "args": ["google-analytics-mcp"]
    }
  }
}
```

### C. Claude Desktop (`claude_desktop_config.json`)
```json
{
  "mcpServers": {
    "google-analytics": {
      "command": "uvx",
      "args": ["google-analytics-mcp"],
      "env": {
        "GA4_PROPERTY_ID": "your_ga4_property_id",
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service_account.json"
      }
    }
  }
}
```

### D. VS Code (Cline / Roo Code / Continue)
```json
{
  "mcpServers": {
    "google-analytics": {
      "command": "npx",
      "args": ["-y", "@surendranb/google-analytics-mcp"]
    }
  }
}
```

---

## šŸ› ļø Tools & Capabilities

| Tool Name | Parameters | Description | Return Type |
|---|---|---|---|
| `get_ga4_data` | `dimensions` (list), `metrics` (list), `date_ranges` (list), `limit` (int) | Runs multi-dimensional GA4 reports with automated metric totals and server-side aggregation. | `JSON / Markdown` |
| `list_accounts` | *(none)* | Lists all accessible Google Analytics accounts and permission levels. | `JSON` |
| `list_properties` | `account_id` (optional) | Lists all GA4 properties associated with an account. | `JSON` |
| `get_property_metadata` | `property_id` (optional) | Fetches complete dimension and metric schemas, custom definitions, and compatibility rules. | `JSON` |
| `run_realtime_report` | `metrics` (list), `dimensions` (list) | Queries real-time active users and event counts from the last 30 minutes. | `JSON` |
| `search_skills` | `query` (string) | Searches built-in GA4 analytical playbooks (e-commerce, channel attribution, bot filtering). | `Markdown` |
| `skill_read` | `skill_name` (string) | Dynamically loads procedural skills and analytical guides from GitHub. | `Markdown` |
| `skills_list` | *(none)* | Lists all available live GA4 analytical skills. | `JSON` |

---

## 🧠 Dynamic Skills & Guided Playbooks

This server ships with built-in analytical recipes that load dynamically from GitHub:
- `traffic-diagnosis`: Step-by-step root cause analysis for sudden traffic drops.
- `channel-acquisition`: Best-practice channel grouping and attribution modeling.
- `ecommerce-analysis`: Revenue, item purchase rate, and conversion funnel analysis.
- `ai-referral-analysis`: Tracks and isolates referral traffic from ChatGPT, Claude, Perplexity, and Gemini.

---

## šŸ”’ Telemetry & Privacy

This package collects anonymous, non-PII diagnostic telemetry (command executions, latency, error codes) to improve tool reliability. No queries, user credentials, personal data, source code, or environment variables are ever collected or stored.

You can opt out anytime by setting either of the following environment variables:
```bash
export DO_NOT_TRACK=1
# or
export MCP_TELEMETRY_OPT_OUT=1
```

---

## šŸ“„ License

MIT License. See [LICENSE](LICENSE) for details.

TDQS

A4.5/5.0

Scored across 10 tools

Disambiguation4/5

The schema exploration tools (list_dimension_categories, list_metric_categories, get_dimensions_by_category, get_metrics_by_category, search_schema, get_property_schema) have some overlap in purpose, but descriptions clearly differentiate browsing vs. searching vs. full schema. The remaining tools (get_ga4_data, search_skills, get_troubleshooting_guide, setup_ga4_access) are distinct.

Naming Consistency4/5

Most tools follow a consistent verb_noun pattern (list_*, get_*, search_*). Minor deviations: setup_ga4_access uses a different verb style, and get_ga4_data is the only tool with a non-descriptive resource name, but overall the pattern is predictable.

Tool Count5/5

10 tools is well-scoped for a GA4 analytics server. Each tool serves a clear purpose: schema discovery (6 tools), data retrieval (1), skills/guidance (2), and setup troubleshooting (1). No redundancy that inflates the count.

Completeness5/5

The tool surface covers the full analytics workflow: discover schema, search for analytical patterns, retrieve data, troubleshoot errors, and fix setup issues. The only minor gap is no direct tool for managing properties or accounts, but that's outside the stated purpose of querying a configured GA4 property.

Maintenance

ActivityActive
ResponsivenessResponsive