Google Analytics MCP Server logo

Google Analytics MCP Server

by ruchernchong

An MCP server implementation for accessing Google Analytics 4 (GA4) data, built using the Model Context Protocol TypeScript SDK. It allows you to retrieve various metrics from your GA4 property.

View on GitHub

Last updated: N/A

What is Google Analytics MCP Server?

This server provides an interface to query Google Analytics 4 (GA4) data using the Model Context Protocol. It allows you to retrieve metrics like page views, active users, events, and user behavior.

How to use Google Analytics MCP Server?

  1. Set up a Google Cloud project with the Analytics Data API enabled and create a service account with appropriate permissions for your GA4 property.
  2. Configure environment variables with your service account credentials and GA4 property ID.
  3. Install the server using Smithery or manually with pnpm install mcp-server-google-analytics.
  4. Start the server with pnpm start.
  5. Configure Claude Desktop to use the server by adding the provided configuration to your Claude Desktop configuration.

Key features of Google Analytics MCP Server

  • 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

Use cases of Google Analytics MCP Server

  • Analyze website traffic and user engagement

  • Track the performance of marketing campaigns

  • Identify popular content and user behavior patterns

  • Monitor key metrics to improve website performance

FAQ from Google Analytics MCP Server

What are the prerequisites for using this server?

You need Node.js 20 or higher, a Google Analytics 4 property, a Google Cloud project with the Analytics Data API enabled, and service account credentials with appropriate permissions.

How do I set up the necessary Google Cloud resources?

Create a Google Cloud project, enable the Analytics Data API, create a service account, download the credentials JSON file, and grant the service account appropriate access to your GA4 property.

What environment variables do I need to configure?

You need to set GOOGLE_CLIENT_EMAIL, GOOGLE_PRIVATE_KEY, and GA_PROPERTY_ID environment variables.

How do I install the server?

You can install it automatically via Smithery or manually using pnpm install mcp-server-google-analytics.

How do I start the server?

Run the command pnpm start.