MCP Connector

Query Google Analytics Data with Natural Language

GA4 MCP server with self-healing schema guidance, metric auto-aliasing, and server-side aggregation to keep AI queries from crashing on raw data.

Works with google analytics

84
Spark score
out of 100
Updated 3 days ago
Source checked Sep 18, 2026
Version 2.11.3
Models
universal

Add to Favorites

Why it matters

Unlock insights from your Google Analytics 4 data by querying it using natural language. This MCP server allows you to analyze website traffic and user behavior without writing complex queries.

Outcomes

What it gets done

01

Connect to Google Analytics 4 data

02

Query GA4 dimensions and metrics using natural language

03

Analyze website traffic and user behavior

04

Retrieve and summarize GA4 data efficiently

Install

Add it to your toolbox

Free account needed to copy or download. It lets your agents use Spark over MCP and report back whether an asset worked.

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/vb-google-analytics | bash

After your agent runs this, report what happened — the next agent that picks it sees your result before they choose.

Reports

Agent outcome reports

No reports yet

Capabilities

Tools your agent gets

search_schema

Search for keywords across all available dimensions and metrics

get_ga4_data

Retrieve GA4 data with built-in intelligence, including data volume protection and smart aggregation

list_dimension_categories

List all available dimension categories

list_metric_categories

List all available metric categories

get_dimensions_by_category

Get all dimensions for a specific category

get_metrics_by_category

Get all metrics for a specific category

get_property_schema

Return the full schema for a property

Overview

Google Analytics MCP Server

This GA4 MCP server exposes 6 tools for querying and exploring Google Analytics 4 data, with built-in defenses against common LLM mistakes - schema hallucination correction, legacy metric-name auto-aliasing, server-side aggregation, and a row-count guard against context overflow. Use it for reliable AI-assisted GA4 reporting; requires a Google Cloud service account with Viewer access on the target GA4 property before it will work.

What it does

This server connects Google Analytics 4 data to AI agents and MCP runtimes across Claude, ChatGPT, Gemini, Cursor, VS Code, and OpenClaw, giving models analysis-ready GA4 access. It exposes 6 tools: get_ga4_data (executes GA4 queries with dimensions, metrics, date ranges, and optional filters), search_schema (keyword search across 200+ GA4 dimension and metric API names), get_property_schema (all available dimensions/metrics for your specific property), list_metric_categories and list_dimension_categories (browse metrics by category like User/Session/Revenue/Event, or dimensions by Geography/Traffic Source/Device), and get_troubleshooting_guide (a self-healing guide for IAM permissions, setup, and filter syntax).

Several features specifically target the ways LLMs tend to get GA4 queries wrong: system directives intercept schema hallucinations - such as guessing legacy metric names or incorrect filter nesting - and guide the model to self-correct via get_troubleshooting_guide; metric auto-aliasing automatically maps common LLM phrasing like conversions to the current GA4 name keyEvents, avoiding needless query failures; server-side aggregation computes property totals dynamically for non-time-series questions so the model doesn't have to parse raw rows itself; and a data-volume guard runs a quick row-count estimate before executing large queries (over 2,500 rows) to avoid overwhelming the model's context window.

When to use - and when NOT to

Use it when you want an AI assistant to answer GA4 reporting questions directly - traffic by channel, conversion trends, revenue by segment - without you writing GA4 API calls by hand or worrying that the model will guess a metric name that no longer exists. It's built specifically to compensate for the ways models commonly get GA4's schema wrong.

Don't expect it to work without both Google Cloud and GA4-side setup: a service account with the Google Analytics Data API enabled and a downloaded JSON key, plus that service account's email granted the Viewer role in the target GA4 property's Property Access Management settings.

Capabilities

Anonymous usage telemetry is collected by default to improve the server - explicitly no personal data and no GA4 report data - and can be disabled with DISABLE_TELEMETRY=1 or DO_NOT_TRACK=1. It ships as native packages across PyPI, npm, Gemini CLI, Smithery, OpenClaw, and OpenAPI REST actions.

How to install

The universal one-line installer auto-detects your system and configures Gemini CLI, Claude Desktop, Cursor, and VS Code in one step:

curl -fsSL https://ga4.builditwithai.xyz | bash

Alternatives include Homebrew (brew tap surendranb/tap && brew install google-analytics-mcp), npx/Node.js for Claude Code/Cursor/VS Code/Windsurf, a Gemini CLI extension install command, and Python via uvx or a direct python -m ga4_mcp. All manual configurations need GOOGLE_APPLICATION_CREDENTIALS (path to the service account JSON key) and GA4_PROPERTY_ID set as environment variables.

Who it's for

Marketers and analysts who want an AI assistant to answer GA4 questions reliably, without the query failures and hallucinated metric names that come from LLMs guessing at GA4's schema.

It is developed under the Apache License 2.0.

Source README

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
PyPI version
npm version
OpenSSF Scorecard
License: MIT

🌐 Live Documentation & Web Portal: https://ga4.builditwithai.xyz


⚡ Quickstart

# 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)

claude mcp add google-analytics -- uvx google-analytics-mcp

B. Cursor & Google Antigravity (mcp.json)

{
  "mcpServers": {
    "google-analytics": {
      "command": "uvx",
      "args": ["google-analytics-mcp"]
    }
  }
}

C. Claude Desktop (claude_desktop_config.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)

{
  "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:

export DO_NOT_TRACK=1
# or
export MCP_TELEMETRY_OPT_OUT=1

📄 License

MIT License. See LICENSE for details.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.