What is Google Analytics MCP Server: Real-Time Sync & Seamless Insights?
Google Analytics MCP Server enables real-time access to Google Analytics 4 (GA4) data through the Model Context Protocol (MCP). Built with TypeScript SDK, it provides a server-side interface to fetch metrics like page views, user behavior, and custom events. This tool bridges GA4 data with applications like Claude Desktop, offering developers a streamlined way to integrate analytics without manual API calls.
How to use Google Analytics MCP Server: Real-Time Sync & Seamless Insights?
Setup Steps
- Install Node.js 20+ and configure a Google Cloud project with Analytics Data API enabled.
- Create a service account, download credentials JSON, and grant access to your GA4 property.
- Set environment variables for credentials and property ID:
export GOOGLE_CLIENT_EMAIL="your-service-account-email"
export GOOGLE_PRIVATE_KEY="your-private-key"
export GA_PROPERTY_ID="your-ga4-property-id"
Integration Example (Claude Desktop)
Add this configuration to your config.json
:
{
"mcpServers": {
"google-analytics": {
"command": "npx",
"args": ["-y", "mcp-server-google-analytics"],
"env": {
"GOOGLE_CLIENT_EMAIL": "[email protected]",
"GOOGLE_PRIVATE_KEY": "your-key",
"GA_PROPERTY_ID": "123456789"
}
}
}
}