The Google Analytics MCP server connects Google Analytics 4 data to AI agents and workflows, providing analysis-ready access to website traffic, user behavior, and performance metrics through tools like live schema discovery, server-side aggregation, and safe defaults that minimize data processing overhead. It enables agents to query GA4 properties directly via the Google Analytics Data API using a service account, reducing the need for manual data wrangling and making analytics insights accessible across Claude, ChatGPT, Cursor, and other MCP-compatible platforms. The server solves the problem of agents spending excessive time preparing raw analytics data for analysis by pre-aggregating results server-side and estimating large datasets to prevent workflow disruptions.
Public tool metadata for what this MCP can expose to an agent.
GOOGLE_ANALYTICS_BATCH_RUN_REPORTSTool to return multiple analytics data reports in a batch. Use when you need to fetch multiple reports for one GA4 property in a single request.2 paramsTool to return multiple analytics data reports in a batch. Use when you need to fetch multiple reports for one GA4 property in a single request.
propertystringrequestsarrayGOOGLE_ANALYTICS_CHECK_COMPATIBILITYTool to list dimensions and metrics compatible with a GA4 report request. Use when you need to validate compatibility of chosen dimensions or metrics before running a report.6 paramsTool to list dimensions and metrics compatible with a GA4 report request. Use when you need to validate compatibility of chosen dimensions or metrics before running a report.
metricsarraypropertystringdimensionsarraymetricFilterobjectdimensionFilterobjectcompatibilityFilterstringCOMPATIBILITY_UNSPECIFIED · COMPATIBLE · INCOMPATIBLEGOOGLE_ANALYTICS_CREATE_AUDIENCE_EXPORTTool to create an audience export. Use after configuring the audience and dimensions to produce a long-running Operation.3 paramsTool to create an audience export. Use after configuring the audience and dimensions to produce a long-running Operation.
parentstringaudiencestringdimensionsarrayGOOGLE_ANALYTICS_CREATE_AUDIENCE_LISTTool to create an audience list. Use when you need to define and asynchronously populate a new AudienceList resource under a GA4 property.4 paramsTool to create an audience list. Use when you need to define and asynchronously populate a new AudienceList resource under a GA4 property.
parentstringaudiencestringdimensionsarraywebhookNotificationobjectGOOGLE_ANALYTICS_CREATE_EXPANDED_DATA_SETTool to create an expanded data set for a property. Use when you need to combine specific dimensions and metrics into a custom dataset after property creation.2 paramsTool to create an expanded data set for a property. Use when you need to combine specific dimensions and metrics into a custom dataset after property creation.
parentstringexpandedDataSetobjectGOOGLE_ANALYTICS_CREATE_ROLLUP_PROPERTYTool to create a GA4 Roll-up Property and optionally initial source links.4 paramsTool to create a GA4 Roll-up Property and optionally initial source links.
accountstringtimeZonestringdisplayNamestringsourcePropertiesarrayGOOGLE_ANALYTICS_GET_ACCOUNTTool to retrieve a single Account by its resource name. Use when you need detailed account info after confirming the account resource name (e.g., accounts/100).1 paramsTool to retrieve a single Account by its resource name. Use when you need detailed account info after confirming the account resource name (e.g., accounts/100).
namestringGOOGLE_ANALYTICS_GET_AUDIENCE_EXPORTTool to get configuration metadata for an Audience Export. Use after creating an Audience Export to retrieve its status and details.1 paramsTool to get configuration metadata for an Audience Export. Use after creating an Audience Export to retrieve its status and details.
namestringGOOGLE_ANALYTICS_GET_AUDIENCE_LISTTool to get configuration metadata about a specific audience list. Use after confirming the audience list resource name.1 paramsTool to get configuration metadata about a specific audience list. Use after confirming the audience list resource name.
namestringGOOGLE_ANALYTICS_GET_KEY_EVENTTool to retrieve a Key Event. Use after confirming the key event resource name.1 paramsTool to retrieve a Key Event. Use after confirming the key event resource name.
namestringGOOGLE_ANALYTICS_GET_METADATATool to get metadata for dimensions, metrics, and comparisons for a GA4 property. Use when you need to discover available fields before building a report.1 paramsTool to get metadata for dimensions, metrics, and comparisons for a GA4 property. Use when you need to discover available fields before building a report.
namestringGOOGLE_ANALYTICS_GET_PROPERTY_QUOTAS_SNAPSHOTTool to retrieve all property quotas organized by category for a given property. Use when you need to check current quota usage for a GA4 property.1 paramsTool to retrieve all property quotas organized by category for a given property. Use when you need to check current quota usage for a GA4 property.
propertystringGOOGLE_ANALYTICS_LIST_ACCOUNTSTool to list all Accounts accessible by the caller. Use when you need to enumerate all Google Analytics accounts your credentials can access.3 paramsTool to list all Accounts accessible by the caller. Use when you need to enumerate all Google Analytics accounts your credentials can access.
pageSizeintegerpageTokenstringshowDeletedbooleanGOOGLE_ANALYTICS_LIST_AUDIENCE_EXPORTSTool to list all audience exports for a GA4 property. Use when you need to fetch its export history after initiating exports.3 paramsTool to list all audience exports for a GA4 property. Use when you need to fetch its export history after initiating exports.
parentstringpageSizeintegerpageTokenstringGOOGLE_ANALYTICS_LIST_AUDIENCE_LISTSTool to list all audience lists for a GA4 property. Use when you need to retrieve a property's configured audience lists after confirming the property ID.3 paramsTool to list all audience lists for a GA4 property. Use when you need to retrieve a property's configured audience lists after confirming the property ID.
parentstringpageSizeintegerpageTokenstringGOOGLE_ANALYTICS_LIST_AUDIENCESTool to list all audiences on a property. Use when you need to fetch all audiences for a GA4 property after confirming its existence.3 paramsTool to list all audiences on a property. Use when you need to fetch all audiences for a GA4 property after confirming its existence.
parentstringpageSizeintegerpageTokenstringGOOGLE_ANALYTICS_LIST_KEY_EVENTSTool to list Key Events. Use when you need to retrieve all key event definitions for a given property.3 paramsTool to list Key Events. Use when you need to retrieve all key event definitions for a given property.
parentstringpageSizeintegerpageTokenstringGOOGLE_ANALYTICS_LIST_PROPERTIESTool to list GA4 properties under a specific account. Use after obtaining an account ID; supports pagination and including soft-deleted properties.4 paramsTool to list GA4 properties under a specific account. Use after obtaining an account ID; supports pagination and including soft-deleted properties.
accountstringpageSizeintegerpageTokenstringshowDeletedbooleanGOOGLE_ANALYTICS_LIST_REPORTING_DATA_ANNOTATIONSTool to list all Reporting Data Annotations on a property. Use when you need to retrieve or inspect annotations for a GA4 property.4 paramsTool to list all Reporting Data Annotations on a property. Use when you need to retrieve or inspect annotations for a GA4 property.
filterstringparentstringpageSizeintegerpageTokenstringGOOGLE_ANALYTICS_LIST_ROLLUP_PROPERTIESTool to list roll-up GA4 properties accessible to the caller. Use when you need to identify roll-up properties across all accessible accounts.1 paramsTool to list roll-up GA4 properties accessible to the caller. Use when you need to identify roll-up properties across all accessible accounts.
pageSizeintegerGOOGLE_ANALYTICS_LIST_SEARCH_ADS360_LINKSTool to list all SearchAds360Links on a property. Use when you need to fetch all Search Ads 360 links for a given property after authenticating.3 paramsTool to list all SearchAds360Links on a property. Use when you need to fetch all Search Ads 360 links for a given property after authenticating.
parentstringpageSizeintegerpageTokenstringGOOGLE_ANALYTICS_QUERY_AUDIENCE_EXPORTTool to query a completed audience export. Use when you need to fetch user rows with pagination.3 paramsTool to query a completed audience export. Use when you need to fetch user rows with pagination.
namestringlimitintegeroffsetintegerGOOGLE_ANALYTICS_QUERY_AUDIENCE_LISTTool to query an audience list. Use when you need to retrieve user rows from a GA4 audience list with pagination.3 paramsTool to query an audience list. Use when you need to retrieve user rows from a GA4 audience list with pagination.
namestringlimitintegeroffsetintegerGOOGLE_ANALYTICS_RUN_FUNNEL_REPORTTool to run a GA4 funnel report. Use when you need a customized funnel analysis report for a given property.10 paramsTool to run a GA4 funnel report. Use when you need a customized funnel analysis report for a given property.
limitintegerfunnelobjectpropertystringsegmentsarraydateRangesarraydimensionFilterobjectfunnelBreakdownobjectfunnelNextActionobjectreturnPropertyQuotabooleanfunnelVisualizationTypestringSTANDARD_FUNNEL · TRENDED_FUNNELGOOGLE_ANALYTICS_RUN_REPORTTool to run a customized GA4 data report. Use when you need event data after specifying dimensions, metrics, and date ranges.15 paramsTool to run a customized GA4 data report. Use when you need event data after specifying dimensions, metrics, and date ranges.
limitintegeroffsetintegermetricsarrayorderBysarraypropertystringcohortSpecobjectdateRangesarraydimensionsarraycomparisonsarraycurrencyCodestringmetricFilterobjectkeepEmptyRowsbooleandimensionFilterobjectmetricAggregationsarrayreturnPropertyQuotaboolean
mcp-name: io.github.surendranb/google-analytics-mcp
Connect Google Analytics 4 data to AI agents, agentic workflows, and MCP clients. Give agents analysis-ready access to website traffic, user behavior, and performance data with schema discovery, server-side aggregation, and safe defaults that reduce data wrangling.
Built for: AI agents, analyst copilots, and MCP runtimes across Claude, ChatGPT, Cursor, Windsurf, and custom hosts.
I also built a Google Search Console MCP that enables you to mix & match the data from both the sources
---Check your Python setup:
# Check Python version (need 3.10+)
python --version
python3 --version
# Check pip
pip --version
pip3 --version
Required:
client_email fieldga4-mcp-server@your-project.iam.gserviceaccount.com)123456789)
Verify your credentials:
pip install google-analytics-data
Create a test script (test_ga4.py):
import os
from google.analytics.data_v1beta import BetaAnalyticsDataClient
# Set credentials path
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/path/to/your/service-account-key.json"
# Test connection
client = BetaAnalyticsDataClient()
print("✅ GA4 credentials working!")
Run the test:
python test_ga4.py
If you see "✅ GA4 credentials working!" you're ready to proceed.
There are two supported ways to launch the server:
ga4-mcp-server when the installed console script is available on your PATHpython -m ga4_mcp when you want to use a specific interpreter or virtual environmentpython3 -m pip install google-analytics-mcp
If your machine uses python instead of python3, run:
python -m pip install google-analytics-mcp
Use this when ga4-mcp-server is available on your PATH:
{
"mcpServers": {
"ga4-analytics": {
"command": "ga4-mcp-server",
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json",
"GA4_PROPERTY_ID": "123456789"
}
}
}
}
Use this when you want to pin the exact Python runtime or when the console script is not on your PATH.
If python3 --version worked:
{
"mcpServers": {
"ga4-analytics": {
"command": "python3",
"args": ["-m", "ga4_mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json",
"GA4_PROPERTY_ID": "123456789"
}
}
}
}
If python --version worked:
{
"mcpServers": {
"ga4-analytics": {
"command": "python",
"args": ["-m", "ga4_mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json",
"GA4_PROPERTY_ID": "123456789"
}
}
}
}
git clone https://github.com/surendranb/google-analytics-mcp.git
cd google-analytics-mcp
python3 -m venv .venv
source .venv/bin/activate
python -m pip install .
If you plan to modify the package locally, use python -m pip install -e . instead.
MCP Configuration:
{
"mcpServers": {
"ga4-analytics": {
"command": "/full/path/to/google-analytics-mcp/.venv/bin/python",
"args": ["-m", "ga4_mcp"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/your/service-account-key.json",
"GA4_PROPERTY_ID": "123456789"
}
}
}
}
Replace these placeholders in your MCP configuration:
/path/to/your/service-account-key.json with the absolute path to your JSON key123456789 with your numeric GA4 Property ID/full/path/to/google-analytics-mcp/.venv/bin/python with your virtual environment's Python path (Method B only)Once configured, ask your MCP client questions like:
Try these example queries to see the MCP's analytical capabilities:
Show me a map of visitors by city for the last 30 days, with a breakdown of new vs returning users
This demonstrates:
Compare average session duration and pages per session by device category and browser over the last 90 days
This demonstrates:
Show me conversion rates and revenue by traffic source and campaign, comparing last 30 days vs previous 30 days
This demonstrates:
What are my top 10 pages by engagement rate, and how has their performance changed over the last 3 months?
This demonstrates:
This MCP server includes built-in optimizations to prevent context window crashes and ensure smooth operation:
limit - Set maximum number of rows to returnproceed_with_large_dataset=True - Override warnings for large datasetsenable_aggregation=False - Disable automatic aggregationestimate_only=True - Get row count estimates without fetching data# This query would normally return 2,605 rows and crash context window
get_ga4_data(
dimensions=["date", "pagePath", "country"],
date_range_start="90daysAgo"
)
# Returns: {"warning": True, "estimated_rows": 2605, "suggestions": [...]}
# Use monthly aggregation instead
get_ga4_data(
dimensions=["month", "pagePath", "country"],
date_range_start="90daysAgo"
)
# Returns: Clean monthly data with manageable row count
The server provides a suite of tools for data reporting and schema discovery.
search_schema - Searches for a keyword across all available dimensions and metrics. This is the most efficient way to discover fields for a query.get_ga4_data - Retrieve GA4 data with built-in intelligence for better and safer results (includes data volume protection, smart aggregation, and intelligent sorting).list_dimension_categories - Lists all available dimension categories.list_metric_categories - Lists all available metric categories.get_dimensions_by_category - Gets all dimensions for a specific category.get_metrics_by_category - Gets all metrics for a specific category.get_property_schema - Returns the complete schema for the property (Warning: this can be a very large object).Access to 200+ GA4 dimensions and metrics organized by category:
If ga4-mcp-server is not found:
python -m ga4_mcpIf you get No module named ga4_mcp:
/full/path/to/python -m pip install google-analytics-mcp
Install the package with the exact interpreter you reference in your MCP configuration.
Permission errors:
# Try user install instead of system-wide
python -m pip install --user google-analytics-mcp
If the server says the credentials file is missing:
If the server says GA4_PROPERTY_ID is invalid or queries return no data:
123456789)G-XXXXXXXXXX)API quota/rate limit errors:
google-analytics-mcp/
├── ga4_mcp/ # Main package directory
│ ├── server.py # Core server logic
│ ├── coordinator.py # MCP instance
│ └── tools/ # Tool definitions (reporting, metadata)
├── pyproject.toml # Package configuration for PyPI
├── requirements.txt # Dependencies for local dev
├── README.md # This file
└── ...
Apache License 2.0
YOUR_API_KEY*secretYour API key for the service
io.github.infoinlet-marketplace/mcp-observability
betterdb-inc/monitor
com.mcparmory/datadog
thotischner/observability-mcp
io.github.tantiope/datadog-mcp
io.github.us-all/datadog