Gtm Ga4 logo

Gtm Ga4

Manage GTM workspaces and consent, create versions, and run GA4 standard, realtime, and custom-dimension operations through MCP.

Install Gtm Ga4

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

STDIONode.js
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "gtm-ga4": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-gtm-ga4"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "YOUR_VALUE_HERE",
        "GTM_ACCOUNT_ID": "YOUR_VALUE_HERE",
        "GTM_CONTAINER_ID": "YOUR_VALUE_HERE",
        "GA4_PROPERTY_ID": "YOUR_VALUE_HERE",
        "GTM_SANDBOX_WORKSPACE_ID": "YOUR_VALUE_HERE",
        "MCP_SERVER_NAME": "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 GOOGLE_APPLICATION_CREDENTIALS=YOUR_VALUE_HERE --env GTM_ACCOUNT_ID=YOUR_VALUE_HERE --env GTM_CONTAINER_ID=YOUR_VALUE_HERE --env GA4_PROPERTY_ID=YOUR_VALUE_HERE --env GTM_SANDBOX_WORKSPACE_ID=YOUR_VALUE_HERE --env MCP_SERVER_NAME=YOUR_VALUE_HERE --transport stdio gtm-ga4 -- npx -y mcp-gtm-ga4

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

We couldn’t confirm it starts correctly

We hit an unexpected error while testing this listing automatically.

npx -y mcp-gtm-ga4

Rate limit exceeded, please try again later - you have reached the maximum number of concurrent E2B sandboxes (20). If you need more, please visit 'https://e2b.dev/docs/billing'

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

gtm-ga4 MCP server connects Google Tag Manager workspaces and Google Analytics 4 properties to MCP clients over stdio. It lets agents inspect and modify tags, review triggers and variables, audit consent settings, preview workspaces, and create container versions. GA4 tools cover configurable reports, last-30-minute realtime data, and custom-dimension administration. Reach for it when an agent needs to coordinate tag implementation with analytics reporting while restricting writes to a resolved sandbox workspace.

Use cases

  • Inspect GTM tags and their firing triggers
  • Audit tag consent configurations
  • Create and update sandbox workspace tags
  • Generate GTM container versions
  • Run GA4 and realtime analytics reports

Key features

  • GTM tag, trigger, and variable inspection
  • JSON-based tag creation and merge updates
  • Consent configuration auditing
  • Sandbox workspace write protection
  • GA4 standard and realtime reporting
  • GA4 custom-dimension administration

Tools18

What Gtm Ga4 lets your agent do. Expand a tool for its parameters.

Self-reported~308 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.

11/11 checks healthy over the last 46d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 5d ago via OSV.dev · mcp-gtm-ga4 (npm)

Adoption & maintenance

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

GitHub stars3Stargazers on the source repository.
npm downloads806Package downloads in the last 30 days.
Last commit10d agoMost recent push to the default branch.
Install checkInconclusiveWe hit an unexpected error running the automated check.
Tools exposed18Callable tools this server registers over MCP.
Directory activity2 viewsConfig copies, upvotes, and views on AllMCPs.

How Gtm Ga4 works

What gtm-ga4 does

gtm-ga4 exposes Google Tag Manager and GA4 operations as MCP tools for an AI client. GTM capabilities include listing tags with consent status and firing triggers, retrieving complete tag configurations, applying JSON merge patches to existing tags, creating tags from JSON definitions, listing triggers and variables, auditing tag consent configuration, generating a workspace preview, and creating a container version.

GA4 capabilities include running reports with selected dimensions, metrics, date ranges, and filters; querying realtime data from the previous 30 minutes; listing custom dimensions; and creating custom dimensions for a property.

How it works

The server uses the Google Tag Manager v2 API for container operations, the Google Analytics Data client for reporting, and the Google Analytics Admin client for custom-dimension administration. MCP messages travel over the SDK's stdio transport, so a client launches the Node.js process and passes configuration through its environment.

Write operations check that the requested workspace matches the resolved sandbox workspace before proceeding. Requests targeting another workspace are rejected with a safety error. If no workspace override is set, the server resolves the Default Workspace.

Setup and configuration

Install the package with npm install mcp-gtm-ga4, or clone the repository, install dependencies, and run its build command. The server can then be launched with Node using the built entry point or through npx mcp-gtm-ga4.

Set GOOGLE_APPLICATION_CREDENTIALS to a Google service-account JSON key or an authorized_user credential file. The service account needs access to the GTM container and GA4 property. For interactive OAuth onboarding, the package provides an auth command and a separate refresh-token helper; these use a Google OAuth client configured with the Tag Manager and Analytics APIs. OAuth output includes credential material, so it should not be redirected into shared logs.

Also configure GTM_ACCOUNT_ID, GTM_CONTAINER_ID, and GA4_PROPERTY_ID. GTM_SANDBOX_WORKSPACE_ID can select a specific workspace; otherwise the Default Workspace is used. MCP_SERVER_NAME changes the server name from its package default.

A client configuration can launch the server with node, pass the built JavaScript file as an argument, and provide these values in an env object. Claude Desktop configuration is supported on macOS and Windows, and Claude Code can use an .mcp.json entry.

Tools and capabilities

  • Inspect and modify GTM tags, including consent status, triggers, full configurations, JSON merge updates, and new tag definitions.
  • List GTM triggers and variables.
  • Audit consent configuration across tags.
  • Preview a workspace and create a container version.
  • Run configurable GA4 and recent realtime reports.
  • List and create GA4 custom dimensions.

The authentication scopes separate GTM container editing, container-version creation, preview and publishing, GA4 read access, and GA4 administration. The server uses retry, circuit-breaker, and timeout policies for resilience, with structured logging through Pino.

Limitations and notes

The runtime expects an explicit credential file through GOOGLE_APPLICATION_CREDENTIALS; it does not fall back to gcloud application-default credentials or compute metadata credentials. Service-account credentials are intended for unattended use, while user OAuth is available when a service account cannot be used.

Keep credential files and MCP configuration containing credentials out of source control. The workspace guard applies to the documented write operations, so an operation aimed at a different workspace is blocked rather than redirected.

The package is licensed under MIT.

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 Gtm Ga4

gtm-ga4 is an MCP server that connects AI clients to Google Tag Manager and Google Analytics 4. Its main tools inspect and modify GTM tags, list triggers and variables, audit consent, preview and version workspaces, run GA4 reports, query realtime data, and manage custom dimensions.

Install it with `npm install mcp-gtm-ga4`, or clone the repository, run `npm install`, and build it with `npm run build`. Launch the built Node entry point from an MCP client, or use `npx mcp-gtm-ga4` with the required environment variables.

Set `GOOGLE_APPLICATION_CREDENTIALS` to a service-account JSON key or an OAuth `authorized_user` credential file. The credential needs access to the target GTM container and GA4 property. The server requires an explicit credential path and does not use Google application-default credential fallbacks.

Yes, gtm-ga4 works with Claude Desktop through its MCP configuration. Add a server entry that launches the Node process or package and supplies `GOOGLE_APPLICATION_CREDENTIALS`, `GTM_ACCOUNT_ID`, `GTM_CONTAINER_ID`, and `GA4_PROPERTY_ID` in the environment.

gtm-ga4 checks write requests against the resolved sandbox workspace and rejects requests for another workspace with a safety error. It uses the Default Workspace unless `GTM_SANDBOX_WORKSPACE_ID` selects a different workspace.

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 PreviewGtm Ga4 AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/gtm-ga4?style=directory)](https://allmcps.com/mcp/gtm-ga4)
HTML Embed
<a href="https://allmcps.com/mcp/gtm-ga4"><img src="https://allmcps.com/api/badge/gtm-ga4?style=directory" alt="Gtm Ga4 on AllMCPs" /></a>