Google Analytics

Provides GA4 data access via the GA Data API and event sending via the Measurement Protocol v2.
  • javascript

1

GitHub Stars

javascript

Language

4 months ago

First Indexed

2 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "leosepulveda-mcp-google-analytics": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-google-analytics"
      ],
      "env": {
        "GA_API_SECRET": "your-api-secret",
        "GA_PROPERTY_ID": "123456789",
        "GA_MEASUREMENT_ID": "G-XXXXXXXXXX",
        "GA_SERVICE_ACCOUNT_JSON": "/path/to/service-account.json"
      }
    }
  }
}

You have an MCP server that connects to Google Analytics 4 to read data with the GA Data API and to send events using the Measurement Protocol. It provides a convenient bridge you can query via MCP clients and keeps credentials and data flow under your control for analytics workflows.

How to use

Set up an MCP client to talk to the Google Analytics MCP server. You can run the server locally via your MCP launcher and then send read requests to fetch GA4 data or dispatch events to GA4 using the Measurement Protocol.

How to install

# Prerequisites
node >= 18
npm >= 6

# Install the MCP server (stdio runtime via npx)
npx -y mcp-google-analytics

# Or install globally and run directly
npm install -g mcp-google-analytics

Configuration and usage notes

Before starting, provide credentials for both reading GA4 data and writing through the Measurement Protocol. You will set environment variables to point to your service account JSON, GA4 property, and GA4 data stream secrets.

{
  "mcpServers": {
    "google_analytics": {
      "command": "npx",
      "args": ["-y", "mcp-google-analytics"],
      "env": {
        "GA_SERVICE_ACCOUNT_JSON": "/path/to/service-account.json",
        "GA_PROPERTY_ID": "123456789",
        "GA_MEASUREMENT_ID": "G-XXXXXXXXXX",
        "GA_API_SECRET": "your-api-secret"
      }
    }
  }
}

Key capabilities you can use

This MCP server exposes reading and writing capabilities via dedicated tools. Use read tools to query GA4 data and write tools to send events or pageviews to GA4.

Security and debugging tips

Enable verbose debugging when you need to diagnose issues with authentication or requests. You can scope debug output to the GA analytics server.

Notes on token usage and optimization

GA4 reports can return large datasets. If you see high token usage, limit the date range, request only the necessary dimensions/metrics, and set sensible result limits.

Available tools

ga_run_report

Run custom GA4 reports by specifying date ranges, dimensions, metrics, and optional filters. Supports limiting results and ordering.

ga_run_realtime_report

Fetch real-time GA4 data for the last 30 minutes, returning metrics and dimensions as configured.

ga_get_metadata

Retrieve all available dimensions and metrics for the configured GA4 property (may be large). Use sparingly.

ga_list_accounts

List all GA accounts accessible with the provided service credentials.

ga_list_properties

List GA4 properties, optionally filtered by account.

ga_get_property

Get detailed information about the configured GA4 property.

ga_list_data_streams

List data streams for the configured GA4 property.

ga_run_pivot_report

Run pivot table reports with row and column dimensions and metric aggregations.

ga_run_funnel_report

Perform funnel analysis to track user progression through defined steps.

ga_batch_run_reports

Execute multiple report requests in a single call to improve efficiency.

ga_send_event

Send custom GA4 events via the Measurement Protocol.

ga_validate_event

Validate events against the GA4 debug endpoint before sending.

ga_send_pageview

Send page view events to GA4.

ga_send_purchase

Send ecommerce purchase events including transactions and item details.

ga_send_login

Send user login events to GA4.

ga_send_signup

Send user signup/registration events to GA4.

ga_send_add_to_cart

Send add-to-cart events to GA4.

ga_send_begin_checkout

Send begin checkout events to GA4.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
Google Analytics MCP Server - leosepulveda/mcp-google-analytics | VeilStrat