Labsco
ruchernchong logo

Google Analytics

β˜… 71

from ruchernchong

Access Google Analytics 4 (GA4) data using the Model Context Protocol.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedPaid serviceAdvanced setup

MseeP.ai Security Assessment Badge

Verified on MseeP

Google Analytics MCP Server

smithery badge

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

Available Functions

runReport

Run a flexible report to get analytics data.

Input:

Copy & paste β€” that's it
{
  "startDate": "2024-01-01",
  "endDate": "2024-01-31",
  "dimensions": [{ "name": "country" }, { "name": "city" }],
  "metrics": [{ "name": "activeUsers" }, { "name": "newUsers" }],
  "dimensionFilter": {
    "filter": {
      "fieldName": "country",
      "stringFilter": {
        "value": "United States"
      }
    }
  }
}

getPageViews

Get page view metrics for a specific date range:

Copy & paste β€” that's it
{
  "startDate": "2024-01-01",
  "endDate": "2024-01-31",
  "dimensions": ["page", "country"] // Optional
}

getActiveUsers

Get active users metrics:

Copy & paste β€” that's it
{
  "startDate": "2024-01-01",
  "endDate": "2024-01-31"
}

getEvents

Get event metrics:

Copy & paste β€” that's it
{
  "startDate": "2024-01-01",
  "endDate": "2024-01-31",
  "eventName": "purchase" // Optional
}

getUserBehavior

Get user behavior metrics:

Copy & paste β€” that's it
{
  "startDate": "2024-01-01",
  "endDate": "2024-01-31"
}

Security Considerations

  • Least Privilege: Only grant the service account the "Viewer" role in Google Analytics.
  • Key Management: Keep your service account key file secure and do not expose it in client-side code.
  • Environment Variables: Use environment variables to store sensitive information like the client email, private key, and property ID.

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.