Google Analytics 4 logo

Google Analytics 4

Manage GA4 properties, streams, conversions, custom definitions, links, credentials, and reports through MCP tools.

Install Google Analytics 4

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "google-analytics-4-2": {
      "command": "uvx",
      "args": [
        "google-analytics-4-mcp"
      ],
      "env": {
        "GA_CREDENTIALS": "YOUR_VALUE_HERE",
        "GA_CREDENTIALS_PATH": "YOUR_VALUE_HERE"
      }
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Values are written into the snippet above so you can paste it as is. They never leave your browser.

Claude Code command
claude mcp add --env GA_CREDENTIALS=YOUR_VALUE_HERE --env GA_CREDENTIALS_PATH=YOUR_VALUE_HERE --transport stdio google-analytics-4-2 -- uvx google-analytics-4-mcp

Run in your terminal. Add --scope project to share it with your team through .mcp.json.

We couldn’t confirm it starts correctly

We ran the install command but it didn't respond within our test window — this can mean a slow first-time install rather than a real problem.

uvx google-analytics-4-mcp

Process exited before answering initialize.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

Google Analytics 4 MCP server connects an MCP client to Google Analytics Admin and Data APIs using a Google Cloud service account. It can create and manage properties and web data streams, configure conversions and custom definitions, link Google Ads accounts, and generate tracking setup details. Reporting tools query historical and real-time data with dimensions, metrics, date ranges, and filters. Reach for it when an agent needs to administer GA4 or retrieve analytics data without a browser-based OAuth flow.

Use cases

  • Create a GA4 property and web data stream
  • Generate a gtag.js tracking snippet
  • Mark events as conversions
  • Run filtered GA4 reports
  • Inspect real-time users and events

Key features

  • Service-account authentication checks
  • GA4 property and data-stream administration
  • Conversion and custom-definition management
  • Google Ads account linking
  • Standard and real-time reporting
  • Dimension and metric metadata lookup

Tools23

What Google Analytics 4 lets your agent do. Expand a tool for its parameters.

Self-reported~258 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

14/14 checks healthy over the last 77d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 2d ago via OSV.dev · google-analytics-4-mcp (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

Last commit9mo agoMost recent push to the default branch.
Install checkInconclusiveDidn't respond in our test window — often a slow first install.
Tools exposed23Callable tools this server registers over MCP.
Directory activity5 viewsConfig copies, upvotes, and views on AllMCPs.

How Google Analytics 4 works

What Google Analytics 4 MCP server does

The Google Analytics 4 MCP server exposes administrative and reporting operations for Google Analytics 4 through MCP. It works with accounts, properties, data streams, key events, custom dimensions, custom metrics, Google Ads links, and Measurement Protocol secrets.

For new property setup, an agent can identify accessible accounts, create a property, add a web data stream, and retrieve the resulting Measurement ID. The server can also produce a gtag.js HTML tracking snippet for installation on a website. Existing resources can be inspected, and properties or streams can be soft-deleted or deleted through the available administration tools.

How it works

Authentication uses a Google Cloud service account rather than an interactive browser session. The service account must have access to the relevant GA4 property, and the Google Analytics Admin API and Google Analytics Data API must be enabled in the associated Google Cloud project.

After the MCP process starts, call check_auth_status to verify the credentials. Account and property discovery can then precede configuration or reporting. run_report accepts dimensions, metrics, dates, filters, and a result limit for standard queries. run_realtime_report returns real-time active-user and event data, while get_metadata helps identify available dimensions and metrics.

Setup and configuration

Create a service account in Google Cloud Console and download its JSON key. Grant the service account email Editor access under the GA4 property's Property Access Management settings. Enable both required APIs in the same Google Cloud environment.

Credentials can be supplied in GA_CREDENTIALS as the complete JSON document, or stored at the path specified by GA_CREDENTIALS_PATH. The environment variable takes precedence when both are present. The documented default file location is ~/.google-analytics-4-mcp/credentials.json.

Running from source uses uv run google-analytics-4-mcp after cloning the repository.

Tools and capabilities

The Google Analytics 4 MCP server includes tools for:

  • Checking service-account authentication and listing accessible accounts or properties.
  • Creating, reading, and deleting GA4 properties and data streams.
  • Creating web streams, retrieving Measurement IDs, and generating gtag.js snippets.
  • Listing, creating, and removing key events, custom dimensions, and custom metrics.
  • Listing and creating Google Ads links.
  • Getting or creating a Measurement Protocol secret.
  • Running standard, real-time, and metadata queries through the Data API.

Limitations and notes

The provided setup requires a Google Cloud service account, API enablement, and explicit GA4 property access. The documented credential flow does not use a browser consent screen or refreshable user tokens. Administrative changes include destructive operations such as property soft deletion and stream deletion, so agents should confirm targets before invoking them. The available report dimensions and metrics depend on the metadata exposed by the connected GA4 property and API.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Google Analytics 4

Google Analytics 4 is an MCP server that connects AI clients to Google Analytics Admin and Data APIs through a Google Cloud service account. Its main tools manage accounts, properties, data streams, conversions, custom definitions, and Google Ads links, while report tools query historical, real-time, and metadata data.

Install it with `uvx google-analytics-4-mcp`, then add the command and credentials to your MCP client configuration. The documented options include Claude Code, Claude Desktop, or running from source with `uv run google-analytics-4-mcp`.

Authenticate it with a Google Cloud service-account JSON key. Put the complete JSON in `GA_CREDENTIALS`, or save it at the `GA_CREDENTIALS_PATH` location, then grant the service account Editor access to the GA4 property and enable both required APIs.

Yes, it can generate a gtag.js HTML tracking snippet. Create or select a property and web data stream first, then call `get_tracking_snippet`; creating a web stream also provides the Measurement ID needed for website tracking.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewGoogle Analytics 4 AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/google-analytics-4-2?style=directory)](https://allmcps.com/mcp/google-analytics-4-2)
HTML Embed
<a href="https://allmcps.com/mcp/google-analytics-4-2"><img src="https://allmcps.com/api/badge/google-analytics-4-2?style=directory" alt="Google Analytics 4 on AllMCPs" /></a>