home / mcp / ga4 mcp server

GA4 MCP Server

Google Analytics 4 MCP Server for Claude, Cursor, Windsurf etc - Access GA4 data through natural language with 200+ dimensions & metrics

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "surendranb-google-analytics-mcp": {
      "command": "python3",
      "args": [
        "-m",
        "ga4_mcp_server"
      ],
      "env": {
        "GA4_PROPERTY_ID": "123456789",
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json"
      }
    }
  }
}

You can connect Google Analytics 4 data to MCP clients to query website traffic, user behavior, and analytics data in natural language. This server exposes 200+ GA4 dimensions and metrics and works with Claude, Cursor, and other MCP clients for flexible data analysis.

How to use

Connect the GA4 MCP server to an MCP client and start asking questions about your analytics data. Use the available tools to discover dimensions and metrics, fetch GA4 data with built-in safeguards, and perform multi‑dimensional analyses like revenue by country, traffic source performance, and user engagement trends. You can explore dimension categories, run time-based comparisons, and get structured results suitable for visualization.

How to install

Prerequisites: you need Python 3.10 or higher, and you must have a GA4 property with data plus a service account with Analytics Reporting API access.

Method A: pip install (Recommended)

{
  "mcpServers": {
    "ga4-analytics": {
      "command": "python3",
      "args": ["-m", "ga4_mcp_server"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json",
        "GA4_PROPERTY_ID": "123456789"
      }
    }
  }
}

If your system uses the Python 3 path, you can also use python instead of python3 with the same configuration. Use the corresponding command and ensure the environment variables point to your JSON key and GA4 property ID.

Method B: GitHub download

git clone https://github.com/surendranb/google-analytics-mcp.git
 cd google-analytics-mcp
 python3 -m venv venv
 source venv/bin/activate
 pip install -r requirements.txt

Additional method configurations

You can run the MCP server with the same GA4 properties using the exact command patterns shown below. These configurations assume you have already downloaded the code, set up a virtual environment (for Method B), and prepared your service account key.

{
  "mcpServers": {
    "ga4-analytics": {
      "command": "/full/path/to/ga4-mcp-server/venv/bin/python",
      "args": ["/full/path/to/ga4-mcp-server/ga4_mcp_server.py"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json",
        "GA4_PROPERTY_ID": "123456789"
      }
    }
  }
}

Available tools

search_schema

Search across all available GA4 dimensions and metrics to discover fields for a query.

get_ga4_data

Retrieve GA4 data with built‑in protections like data volume checks, smart aggregation, and intelligent sorting.

list_dimension_categories

List all available GA4 dimension categories.

list_metric_categories

List all available GA4 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 complete GA4 property schema.