mcp-server-google-analytics

  • Customer Data Platforms
TypeScript
2
-
security - not tested
F
license - not found
-
quality - not tested

An MCP server implementation for accessing Google Analytics 4 (GA4) data, built using the Model Context Protocol TypeScript SDK.

  1. Tools
  2. Prompts
  3. Resources
  4. Server Configuration
  5. README.md

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

Tools

Functions exposed to the LLM to take actions

NameDescription

No tools

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
GA_PROPERTY_IDYesYour Google Analytics 4 property ID.
GOOGLE_PRIVATE_KEYYesYour private key for the Google service account.
GOOGLE_CLIENT_EMAILYesYour service account email for the Google Cloud project.
README.md

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

  1. Create a Google Cloud project and enable the Analytics Data API
  2. Create a service account and download the credentials JSON file
  3. Grant the service account appropriate access to your GA4 property
  4. Set up environment variables:
export GOOGLE_CLIENT_EMAIL="your-service-account@project.iam.gserviceaccount.com" export GOOGLE_PRIVATE_KEY="your-private-key" export GA_PROPERTY_ID="your-ga4-property-id"

Installation

pnpm install mcp-server-google-analytics

Usage

Starting the Server

pnpm start

Configuration in Claude Desktop

Add this to your Claude Desktop configuration:

{ "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" } } } }

Available Functions

getPageViews

Get page view metrics for a specific date range:

{ "startDate": "2024-01-01", "endDate": "2024-01-31", "dimensions": ["page", "country"] // Optional }

getActiveUsers

Get active users metrics:

{ "startDate": "2024-01-01", "endDate": "2024-01-31" }

getEvents

Get event metrics:

{ "startDate": "2024-01-01", "endDate": "2024-01-31", "eventName": "purchase" // Optional }

getUserBehavior

Get user behavior metrics:

{ "startDate": "2024-01-01", "endDate": "2024-01-31" }

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:

Alternative MCP servers

  • A
    security
    F
    license
    A
    quality
    Helps AI read GitHub repository structure and important files. Want to quickly understand what a repo is about? Prompt it with "read https://github.com/adhikasp/mcp-git-ingest and determine how the code technically works".
  • A
    security
    A
    license
    A
    quality
    This is a server that lets your LLMs (like Claude) talk directly to your BigQuery data! Think of it as a friendly translator that sits between your AI assistant and your database, making sure they can chat securely and efficiently.
    MIT
  • -
    security
    A
    license
    -
    quality
    A Model Context Protocol server that provides access to BigQuery. This server enables LLMs to inspect database schemas and execute queries.
    MIT
    • Apple
  • -
    security
    A
    license
    -
    quality
    A Model Context Protocol server enabling Claude to maintain user context through Apache Unomi profile management.
    Apache-2.0
    • Apple