Google Analytics
An MCP server implementation for accessing Google Analytics 4 (GA4) data, built using the Model Context Protocol TypeScript SDK.
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
Maintainer
Works with
Installation
NPM
npx -y @toolsdk.ai/mcp-server-google-analyticsManual Installation
npx -y @toolsdk.ai/mcp-server-google-analyticsConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
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
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.
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.
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.
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"
}
}
}
}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.
Google Analytics Alternatives — Similar Analytics Servers
Looking for alternatives to Google Analytics? Here are other popular analytics servers you can use with Claude, Cursor, and VS Code.
OpenMetadata
★ 14.0kOpenMetadata is a unified metadata platform for data discovery, data observability, and data governance powered by a central metadata repository, in-depth column level lineage, and seamless team collaboration.
Superset
★ 10.9kAn MCP server that provides AI assistants with full access to Apache Superset instances, enabling interaction with dashboards, charts, datasets, databases, and SQL execution capabilities.
Horizon
★ 4.4k📡 Your own AI-powered news radar. Generates daily briefings in English & Chinese. | 用 AI 构建你专属的新闻雷达
MCP Server Chart
★ 4.1kEnables generation of 25+ types of charts and data visualizations using AntV, including bar charts, line charts, maps, mind maps, and specialized diagrams like fishbone and sankey charts. Supports both statistical charts and geographic visualizations
Muapi CLI
★ 997Official CLI for muapi.ai — generate images, videos & audio from the terminal. MCP server, 14 AI models, npm + pip installable.
Weather MCP Server
★ 907Weather Data Fetcher MCP server built with Node.js, MCP SDK, and Zod. Provides weather details like temperature and forecast for cities such as Noida and Delhi via a registered tool. Simplifies API integration, enabling structured responses for clien
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.
Set Up Google Analytics in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
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.