mcp-server-google-analytics
- Customer Data Platforms
An MCP server implementation for accessing Google Analytics 4 (GA4) data, built using the Model Context Protocol TypeScript SDK.
Prompts
Interactive templates invoked by user choice
Name | Description |
---|---|
No prompts |
Resources
Contextual data attached and managed by the client
Name | Description |
---|---|
No resources |
Tools
Functions exposed to the LLM to take actions
Name | Description |
---|---|
No tools |
Server Configuration
Describes the environment variables required to run the server.
Name | Required | Description | Default |
---|---|---|---|
GA_PROPERTY_ID | Yes | Your Google Analytics 4 property ID. | |
GOOGLE_PRIVATE_KEY | Yes | Your private key for the Google service account. | |
GOOGLE_CLIENT_EMAIL | Yes | Your service account email for the Google Cloud project. |
Google Analytics MCP Server
An MCP server implementation for accessing Google Analytics 4 (GA4) data, built using the Model Context Protocol TypeScript SDK.
Features
- Get page view metrics with customizable dimensions
- Track active and new users over time
- Analyze specific events and their metrics
- Monitor user behavior metrics (session duration, bounce rate)
- Flexible date range selection for all queries
Prerequisites
- Node.js 20 or higher
- Google Analytics 4 property
- Google Cloud project with Analytics Data API enabled
- Service account credentials with appropriate permissions
Setup
- Create a Google Cloud project and enable the Analytics Data API
- Create a service account and download the credentials JSON file
- Grant the service account appropriate access to your GA4 property
- Set up environment variables:
Installation
Usage
Starting the Server
Configuration in Claude Desktop
Add this to your Claude Desktop configuration:
Available Functions
getPageViews
Get page view metrics for a specific date range:
getActiveUsers
Get active users metrics:
getEvents
Get event metrics:
getUserBehavior
Get user behavior metrics:
Security Considerations
- Always use environment variables for sensitive credentials
- Implement appropriate CORS settings
- Follow the principle of least privilege when setting up service account permissions
- Regularly rotate service account credentials
- Monitor API usage and implement rate limiting if needed
Contributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
GitHub Badge
Glama performs regular codebase and documentation scans to:
- Confirm that the MCP server is working as expected.
- Confirm that there are no obvious security issues with dependencies of the server.
- Extract server characteristics such as tools, resources, prompts, and required parameters.
Our directory badge helps users to quickly asses that the MCP server is safe, server capabilities, and instructions for installing the server.
Copy the following code to your README.md file: