Google Analytics 4 MCP Server for Claude, Cursor, Windsurf etc - Access GA4 data through natural language with 200+ dimensions & metrics
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.
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.
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.txtYou 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"
}
}
}
}Search across all available GA4 dimensions and metrics to discover fields for a query.
Retrieve GA4 data with builtβin protections like data volume checks, smart aggregation, and intelligent sorting.
List all available GA4 dimension categories.
List all available GA4 metric categories.
Get all dimensions for a specific category.
Get all metrics for a specific category.
Return the complete GA4 property schema.