Google Analytics

v1.0.0Analyticsstable

An MCP server implementation for accessing Google Analytics 4 (GA4) data, built using the Model Context Protocol TypeScript SDK.

google-analyticsmcpai-integration
Share:
72
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 mcp server implementation for accessing google analytics 4 (ga4) data, built using the model context protocol typescript sdk.

An MCP server implementation for accessing Google Analytics 4 (GA4) data, built using the Model Context Protocol TypeScript SDK.

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

Features

  • get_report
  • get_realtime_data

Use Cases

Access Google Analytics 4 (GA4) data through MCP.
Query and analyze website and app metrics.
ruchernchong

Maintainer

LicenseMIT License
Languagejavascript
Versionv1.0.0
UpdatedApr 2, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y @toolsdk.ai/mcp-server-google-analytics

Manual Installation

npx -y @toolsdk.ai/mcp-server-google-analytics

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 connects AI assistants to Google Analytics 4 property data, letting them run flexible reports, retrieve real-time user counts, analyze page views, track events, and measure user behavior metrics entirely through natural language. It authenticates via a Google service account, so there is no OAuth browser flow required after initial setup. Marketing teams and developers use it to query GA4 data conversationally — asking questions like 'which pages had the most traffic last month?' — without exporting CSV files or writing API code.

Prerequisites

  • A Google Cloud project with the Google Analytics Data API (v1) enabled
  • A Google service account with Viewer access granted to your GA4 property
  • A service account JSON key file downloaded from Google Cloud Console
  • Your GA4 Property ID (found in GA4 Admin > Property Settings, format: numeric digits only)
  • Node.js 18 or later and an MCP client such as Claude Desktop
1

Create a Google Cloud service account

In Google Cloud Console, create a service account for the MCP server, then generate and download a JSON key file. Copy the client_email and private_key values from the JSON for use as environment variables.

2

Grant the service account access to GA4

In your GA4 property, go to Admin > Property Access Management and add the service account email address with Viewer role.

3

Find your GA4 Property ID

In GA4, go to Admin > Property Settings. Your Property ID is the numeric value shown (e.g. 123456789). Do not use the Measurement ID (G-XXXXXXXX) — the server needs the numeric property ID.

4

Configure the MCP server in claude_desktop_config.json

Add the Google Analytics server entry with your service account credentials and property ID as environment variables.

{
  "mcpServers": {
    "google-analytics": {
      "command": "npx",
      "args": ["-y", "@toolsdk.ai/mcp-server-google-analytics"],
      "env": {
        "GOOGLE_CLIENT_EMAIL": "[email protected]",
        "GOOGLE_PRIVATE_KEY": "-----BEGIN PRIVATE KEY-----\nYOUR_KEY_HERE\n-----END PRIVATE KEY-----\n",
        "GA_PROPERTY_ID": "123456789"
      }
    }
  }
}
5

Restart Claude Desktop and test a query

Restart your MCP client and ask a simple analytics question to verify the connection. A successful response with metric data confirms the setup is complete.

Google Analytics Examples

Client configuration

Full Claude Desktop config for @toolsdk.ai/mcp-server-google-analytics with service account credentials.

{
  "mcpServers": {
    "google-analytics": {
      "command": "npx",
      "args": ["-y", "@toolsdk.ai/mcp-server-google-analytics"],
      "env": {
        "GOOGLE_CLIENT_EMAIL": "[email protected]",
        "GOOGLE_PRIVATE_KEY": "-----BEGIN PRIVATE KEY-----\nMIIEvQ...\n-----END PRIVATE KEY-----\n",
        "GA_PROPERTY_ID": "123456789"
      }
    }
  }
}

Prompts to try

Natural language queries to explore your GA4 data through the MCP server.

- "How many active users are on my site right now?"
- "Show me page views for the last 30 days broken down by page path"
- "Which countries sent the most users to my site last month?"
- "What were the top 10 pages by views in January 2025?"
- "Show me session duration and bounce rate for the last 7 days"
- "How many times was the 'purchase' event triggered last week?"

Troubleshooting Google Analytics

Error: 'The caller does not have permission' or 403 from the GA4 API

Ensure the service account email has been added as a Viewer in GA4 Admin > Property Access Management. Also verify the Google Analytics Data API is enabled in your Google Cloud project at console.cloud.google.com/apis.

GOOGLE_PRIVATE_KEY causes JSON parse errors in the config file

The private key must have literal \n sequences (not actual newlines) within the JSON string. Copy the key from the downloaded JSON file and ensure each newline in the PEM block is represented as \n in the config.

GA_PROPERTY_ID not found error from the API

Use the numeric Property ID from GA4 Admin > Property Settings (e.g. 123456789), not the web stream Measurement ID (G-XXXXXXXX). These are different values and only the numeric ID works with the Data API.

Frequently Asked Questions about Google Analytics

What is Google Analytics?

Google Analytics is a Model Context Protocol (MCP) server that mcp server implementation for accessing google analytics 4 (ga4) data, built using the model context protocol typescript sdk. 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 @toolsdk.ai/mcp-server-google-analytics. 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 MIT License 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": { "command": "npx", "args": ["-y", "@toolsdk.ai/mcp-server-google-analytics"] } } }

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