mcp -google-analytics
Model Context Protocol server for Google Analytics, enabling LLMs to fetch and analyze web analytics data
claude mcp add --transport stdio ruchernchong-mcp-server-google-analytics npx -y mcp-server-google-analytics \ --env GA_PROPERTY_ID="your-ga4-property-id" \ --env GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END PRIVATE KEY-----\n" \ --env GOOGLE_CLIENT_EMAIL="your-service-account@project.iam.gserviceaccount.com"
How to use
This MCP server provides access to Google Analytics 4 (GA4) data via a TypeScript SDK-based MCP implementation. It exposes functions to retrieve flexible analytics data, including page views, active users, events, and user behavior metrics. After configuring the required Google Analytics credentials through environment variables, you can query GA4 data using the server's available endpoints like runReport, getPageViews, getActiveUsers, getEvents, and getUserBehavior. The RunReport function supports custom dimensions, metrics, date ranges, and optional filters to tailor analytics queries to your needs.
How to install
Prerequisites:
- Node.js 20 or higher
- Access to a Google Analytics 4 property with the Analytics Data API enabled
- A service account with credentials (JSON) and a GA4 property to query
Installation options:
- Install via npx (recommended for quick setup):
# Install and run the MCP server using npx
npx -y mcp-server-google-analytics
- Global installation (alternative):
npm install -g mcp-server-google-analytics
- Manual configuration in Claude Desktop (example):
npx -y mcp-server-google-analytics
Configuration in Claude Desktop (example JSON):
{
"mcpServers": {
"google-analytics": {
"command": "npx",
"args": ["-y", "mcp-server-google-analytics"],
"env": {
"GOOGLE_CLIENT_EMAIL": "your-service-account@project.iam.gserviceaccount.com",
"GOOGLE_PRIVATE_KEY": "your-private-key",
"GA_PROPERTY_ID": "your-ga4-property-id"
}
}
}
}
Additional notes
Environment variables:
- GOOGLE_CLIENT_EMAIL and GOOGLE_PRIVATE_KEY come from your Google Cloud service account credentials JSON. Keep these secrets secure and do not expose them in client-side code.
- GA_PROPERTY_ID must be the GA4 property ID you intend to query.
- If using a .env file, ensure it is loaded by your runtime (e.g., with dotenv). Common issues:
- Ensure the Analytics Data API is enabled in Google Cloud Console for the project.
- Confirm the service account has Viewer access to the GA4 property.
- When exchanging keys, preserve newline characters in the private key (escape them properly in shell or config files).
- If you modify environment variables, restart the MCP server to apply changes.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.