Google Analytics
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,
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
Maintainer
Works with
Installation
NPM
npx -y google-analytics-mcpPIP
pip install google-analytics-mcpManual Installation
npx -y google-analytics-mcpConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
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
Install the google-analytics-mcp package
Install the package from PyPI. This provides the ga4-mcp-server console script.
pip install google-analytics-mcpCreate 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.
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"Test the server standalone
Run the server directly to confirm it starts without errors before configuring your MCP client.
ga4-mcp-serverConfigure 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.
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.
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.