Build a Google Analytics 4 MCP server to track user metrics, events, and page views with customizable options
The Google Analytics MCP Server is an implementation designed to facilitate seamless integration of Google Analytics 4 (GA4) data into AI applications, leveraging the Model Context Protocol (MCP). This server enables MCP clients such as Claude Desktop, Continue, and Cursor to interact with GA4 data using a standardized protocol. By abstracting away complex API interactions, this server streamlines the process for developers working on AI projects that require real-time or historical analytics insights.
The Google Analytics MCP Server offers a range of capabilities tailored towards enhancing AI workflows with GA4 data:
These features are implemented using MCP, a universal adapter protocol that allows various AI applications to connect seamlessly with diverse data sources. The server uses the Model Context Protocol TypeScript SDK to ensure compatibility and ease of integration.
The architecture of the Google Analytics MCP Server revolves around MCP's core principles: flexibility, security, and standardization. Here’s an overview:
The implementation involves setting up environment variables, installing dependencies via pnpm
, and starting the server to provide real-time analytics data. Below is an example of how this setup looks:
export GOOGLE_CLIENT_EMAIL="[email protected]"
export GOOGLE_PRIVATE_KEY="your-private-key"
export GA_PROPERTY_ID="your-ga4-property-id"
To get started, follow these steps for setting up and running the Google Analytics MCP Server:
GOOGLE_CLIENT_EMAIL
and GOOGLE_PRIVATE_KEY
.export GOOGLE_CLIENT_EMAIL="[email protected]"
export GOOGLE_PRIVATE_KEY="your-private-key"
export GA_PROPERTY_ID="your-ga4-property-id"
pnpm install mcp-server-google-analytics
pnpm start
The Google Analytics MCP Server excels in providing critical data insights for various AI application use cases:
{
"mcpServers": {
"google-analytics": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-google-analytics"],
"env": {
"GOOGLE_CLIENT_EMAIL": "[email protected]",
"GOOGLE_PRIVATE_KEY": "your-private-key",
"GA_PROPERTY_ID": "your-ga4-property-id"
}
}
}
}
This configuration enables Claude Desktop to interact with GA4 data through the MCP server, providing a seamless and integrated experience.
The Google Analytics MCP Server is designed to be compatible with major AI applications:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
To ensure robust security and performance, follow these best practices:
GOOGLE_CLIENT_EMAIL
and GOOGLE_PRIVATE_KEY
.Q: How do I install the Google Analytics MCP Server?
A: You can install it using pnpm
by running pnpm install mcp-server-google-analytics
.
Q: What are the minimum system requirements for running this server?
A: Node.js 20 or higher is required along with a valid Google Analytics property and service account credentials.
Q: Can I use this server with other AI applications besides Claude Desktop?
A: Yes, it supports major MCP clients such as Continue and Cursor but may require additional configurations for full compatibility.
Q: How do I ensure the security of sensitive data in my environment variables?
A: Use strong encryption methods or keep your keys stored securely outside configuration files where possible.
Q: What metrics can be analyzed using this server?
A: The server allows analysis of page views, active users, specific events, user behavior, and more, all customizable with date ranges.
Contributions are welcome! Please read our Contributing Guide for details on how to contribute to the project.
For more information about the Model Context Protocol and its various implementations, visit:
By leveraging the Google Analytics MCP Server, developers can enhance their AI applications with robust GA4 data integration capabilities, providing a powerful toolset for data-driven decision making.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods