
Security News
pnpm 10.12 Introduces Global Virtual Store and Expanded Version Catalogs
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
google-analytics-mcp
Advanced tools
Google Analytics 4 MCP Server - Access GA4 data in Claude, Cursor and other MCP clients
Connect Google Analytics 4 data to Claude, Cursor and other MCP clients. Query your website traffic, user behavior, and analytics data in natural language with access to 200+ GA4 dimensions and metrics.
Compatible with: Claude, Cursor and other MCP clients.
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.
Choose one method:
pip install google-analytics-mcp
MCP Configuration:
First, check your Python command:
python3 --version
python --version
Then use the appropriate configuration:
If python3 --version
worked:
{
"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 python --version
worked:
{
"mcpServers": {
"ga4-analytics": {
"command": "python",
"args": ["-m", "ga4_mcp_server"],
"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
pip install -r requirements.txt
MCP Configuration:
{
"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"
}
}
}
}
Replace these placeholders in your MCP configuration:
/path/to/your/service-account-key.json
with your JSON file path123456789
with your GA4 Property ID/full/path/to/ga4-mcp-server/
with your download 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:
The server provides 5 main tools:
get_ga4_data
- Retrieve GA4 data with custom dimensions and metricslist_dimension_categories
- Browse available dimension categorieslist_metric_categories
- Browse available metric categoriesget_dimensions_by_category
- Get dimensions for a specific categoryget_metrics_by_category
- Get metrics for a specific categoryAccess to 200+ GA4 dimensions and metrics organized by category:
If you get "No module named ga4_mcp_server" (Method A):
pip3 install --user google-analytics-mcp
If you get "executable file not found":
python
vs python3
)pip3
instead of pip
if neededPermission errors:
# Try user install instead of system-wide
pip install --user google-analytics-mcp
Credentials not working:
123456789
) ā
G-XXXXXXXXXX
) āAPI quota/rate limit errors:
google-analytics-mcp/
āāā ga4_mcp_server.py # Main MCP server
āāā ga4_dimensions.json # All available GA4 dimensions
āāā ga4_metrics.json # All available GA4 metrics
āāā requirements.txt # Python dependencies
āāā pyproject.toml # Package configuration
āāā README.md # This file
āāā claude-config-template.json # MCP configuration template
MIT License
FAQs
Google Analytics 4 MCP Server - Access GA4 data in Claude, Cursor and other MCP clients
We found that google-analytics-mcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
Security News
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.