Google Analytics

v1.0.0Analyticsstable

Enables AI agents to interact with Google Analytics 4 data, providing tools for historical reporting, real-time activity monitoring, and property management. It supports secure service account authentication to access metrics like traffic summaries,

google-analytics-mcp-servermcpai-integration
Share:
208
Stars
0
Downloads
0
Weekly
0/5

What is Google Analytics?

Google Analytics is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to enables ai agents to interact with google analytics 4 data, providing tools for historical reporting, real-time activity monitoring, and property management. it supports secure service account authent...

Enables AI agents to interact with Google Analytics 4 data, providing tools for historical reporting, real-time activity monitoring, and property management. It supports secure service account authentication to access metrics like traffic summaries,

This server falls under the Analytics category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Enables AI agents to interact with Google Analytics 4 data,

Use Cases

Query Google Analytics 4 data and historical reports.
Monitor real-time activity and traffic summaries.
Analyze metrics through natural language queries.
surendranb

Maintainer

LicenseApache 2.0
Languagepython
Versionv1.0.0
UpdatedMay 15, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y google-analytics-mcp

PIP

pip install google-analytics-mcp

Manual Installation

npx -y google-analytics-mcp

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Google Analytics

The Google Analytics MCP Server gives AI agents direct, authenticated access to Google Analytics 4 data through seven specialized tools covering schema discovery, historical reporting, and dimension/metric exploration. It authenticates via a Google Cloud service account so no OAuth browser flow is required, making it ideal for automated pipelines. Analysts and developers can use this server to query GA4 traffic summaries, conversion rates, session durations, and top pages through natural language without writing API code or navigating the GA4 interface.

Prerequisites

  • Python 3.9+ installed
  • A Google Cloud project with the Google Analytics Data API enabled
  • A service account JSON key file downloaded from Google Cloud Console with Viewer access to your GA4 property
  • Your GA4 numeric Property ID (found in GA4 Admin > Property Settings — not the Measurement ID)
  • Claude Desktop or another MCP client
1

Install the google-analytics-mcp package

Install the package from PyPI. This provides the ga4-mcp-server console script.

pip install google-analytics-mcp
2

Create and download a service account key

In Google Cloud Console, create a service account, grant it the 'Viewer' role on your GA4 property in the GA4 Admin panel, and download the JSON key file. Note the absolute path to this file.

3

Set required environment variables

Export the two required variables: the path to your service account JSON key and your GA4 property ID. Add these to your shell profile or your MCP client config's env block.

export GOOGLE_APPLICATION_CREDENTIALS="/absolute/path/to/service-account-key.json"
export GA4_PROPERTY_ID="123456789"
4

Test the server standalone

Run the server directly to confirm it starts without errors before configuring your MCP client.

ga4-mcp-server
5

Configure Claude Desktop

Add the server block to your Claude Desktop config, passing the environment variables in the env section so the server receives them when launched by Claude.

6

Restart Claude Desktop and query your data

Restart Claude Desktop and ask questions about your GA4 data in plain English. The server translates your request into GA4 API calls and returns structured results.

Google Analytics Examples

Client configuration

Add this to your claude_desktop_config.json. Replace the credential path and property ID with your real values.

{
  "mcpServers": {
    "google-analytics": {
      "command": "ga4-mcp-server",
      "args": [],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/service-account-key.json",
        "GA4_PROPERTY_ID": "123456789"
      }
    }
  }
}

Prompts to try

Ask Claude natural language questions about your GA4 data. The server handles dimension/metric lookup and API pagination automatically.

- "Show me a breakdown of sessions by country for the last 30 days"
- "What are my top 10 pages by engagement rate over the past 3 months?"
- "Compare average session duration by device category over 90 days"
- "Show conversion rates by traffic source and campaign for last week"
- "What dimensions are available in the 'traffic source' category?"

Troubleshooting Google Analytics

Authentication error: Could not load credentials from GOOGLE_APPLICATION_CREDENTIALS

Ensure the env variable points to the absolute path of the JSON key file (not a relative path) and that the file exists and is readable. In the Claude Desktop config, use the full path without ~ expansion.

GA4 API returns 'property not found' or permission denied

Verify that GA4_PROPERTY_ID is the numeric property ID from GA4 Admin > Property Settings (e.g., 123456789), not the G-XXXXXXXX Measurement ID. Also confirm the service account email has been added as a Viewer in GA4 Admin > Account Access Management.

get_property_schema returns a very large object and times out

Use search_schema with a keyword instead of fetching the full schema, or use list_dimension_categories and list_metric_categories to browse the available fields before making a targeted query.

Frequently Asked Questions about Google Analytics

What is Google Analytics?

Google Analytics is a Model Context Protocol (MCP) server that enables ai agents to interact with google analytics 4 data, providing tools for historical reporting, real-time activity monitoring, and property management. it supports secure service account authentication to access metrics like traffic summaries, It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Google Analytics?

Install via npm with the command: npx -y google-analytics-mcp. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).

Which AI clients work with Google Analytics?

Google Analytics works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Google Analytics free to use?

Yes, Google Analytics is open source and available under the Apache 2.0 license. You can use it freely in both personal and commercial projects.

Browse More Analytics MCP Servers

Explore all analytics servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "google-analytics-mcp-server": { "command": "npx", "args": ["-y", "google-analytics-mcp"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Google Analytics?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides