GA4 MCP Server
Allows running reports, viewing top pages, analyzing traffic sources, checking realtime users, and comparing periods using the Google Analytics 4 Data API.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GA4 MCP ServerWhat are my top pages this month?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GA4 MCP Server
A Model Context Protocol (MCP) server that connects Claude Desktop (and other MCP clients) to the Google Analytics 4 Data API — run reports, view top pages, analyze traffic sources, check realtime users, and compare periods.
Features
7 Analytics Tools
Tool | Description |
| List all GA4 properties accessible by the service account |
| Run a custom report with any dimensions and metrics |
| Top pages by sessions with bounce rate and duration |
| Traffic breakdown by source/medium |
| Conversion events and their counts |
| Realtime active users and top pages |
| Compare current vs previous period with percentage changes |
Built-in Reliability
Token-bucket rate limiter — respects GA4's 10 concurrent request limit
Auto-retry on 429/5xx — exponential backoff (2s, 4s, 8s) up to 3 retries
Lazy imports — defers heavy Google client libraries for fast MCP handshake
Actionable error messages — guides users to fix permission, auth, and input errors
Related MCP server: Google Analytics MCP Server
Quick Start
Prerequisites
Python 3.10+
A Google Cloud service account with GA4 access
Claude Desktop (or any MCP-compatible client)
Set Up Google Analytics Access
Create a Google Cloud service account
Enable the Google Analytics Data API and Google Analytics Admin API in your project
Download the service account JSON key file
In GA4: go to Admin > Property Access Management and add the service account email as a Viewer
Installation
git clone https://github.com/luminarylane/ga4-mcp.git
cd ga4-mcp
pip install -r requirements.txtConfiguration
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"ga4": {
"command": "python",
"args": ["/path/to/ga4-mcp/ga4_server.py"],
"env": {
"GA4_CREDENTIALS_PATH": "/path/to/service_account_credentials.json",
"GA4_PROPERTY_ID": "123456789"
}
}
}
}Environment variables:
Variable | Required | Description |
| Yes | Path to service account JSON key file |
| No | Default property ID (can also pass per-tool) |
Alternatively, place service_account_credentials.json in the ga4-mcp/ directory.
Usage Examples
Once configured, ask Claude to:
"What are my top pages this month?"
"Show me traffic sources for the last 7 days"
"How does this week compare to last week?"
"Are there any active users on the site right now?"
"Run a report on sessions by country for the last 90 days"
"What conversion events fired this week?"
"List all GA4 properties I have access to"
Rate Limits
GA4 Data API allows 10 concurrent requests per property. The server handles this with a client-side token bucket and exponential backoff retries.
Troubleshooting
Permission denied (403)
The service account doesn't have access to the GA4 property. Go to GA4 Admin > Property Access Management and add the service account email as a Viewer.
Property not found (404)
Property IDs are numeric (e.g., 123456789), not the measurement ID (G-XXXXXXX). Use ga4_list_properties to find valid IDs.
Authentication failed (401)
Check that GA4_CREDENTIALS_PATH points to a valid service account JSON key file.
Invalid dimension/metric (400)
Check the GA4 Dimensions & Metrics Explorer for valid names. Common mistakes: sessions not session, sessionSource not source, pagePath not page.
Contributing
Fork the repo
Create a feature branch (
git checkout -b feat/my-feature)Make changes and test locally
Submit a pull request
License
MIT License — see LICENSE for details.
Acknowledgments
Anthropic for the MCP specification
Google Analytics Data API for the reporting API
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/luminarylane/ga4-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server