# gtm-ga4 [Health: Active]

**Category:** 🎯 Marketing  
**Repository:** https://github.com/mharnett/mcp-gtm-ga4  
**GitHub Stars:** 3  
**npm Downloads (last month):** 806  
**Views:** 2  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/gtm-ga4

## Description
GTM + GA4 MCP: tag management, consent auditing, workspace versioning, reports.

## Tools
Capabilities this server exposes over MCP:

- **gtm_get_client_context** — Health check and status overview: GTM container path, workspace ID, GA4 property ID and server version
- **gtm_list_tags** — List all tags in the workspace with consent status and firing triggers
- **gtm_get_tag** — Get full tag configuration by tag ID
- **gtm_update_tag** — Update an existing tag (merge patch via JSON)
- **gtm_create_tag** — Create a new tag from a JSON definition
- **gtm_list_triggers** — List all triggers (ID, name, type)
- **gtm_list_variables** — List all variables (ID, name, type)
- **gtm_get_variable** — Get full details of a single variable by ID
- **gtm_create_variable** — Create a new variable in the sandbox workspace
- **gtm_update_variable** — Update a variable (fetch, merge, save) in the sandbox workspace
- **gtm_delete_variable** — Delete a variable from the sandbox workspace (destructive)
- **gtm_audit_consent** — Audit all tags for consent configuration compliance
- **gtm_preview** — Generate a quick preview of the current workspace
- **gtm_create_version** — Create a new container version from the workspace
- **gtm_ga4_run_report** — Run a GA4 report with dimensions, metrics, date range, and filters
- **gtm_ga4_realtime_report** — Run a GA4 realtime report (last 30 minutes)
- **gtm_ga4_list_custom_dimensions** — List all custom dimensions for the property
- **gtm_ga4_create_custom_dimension** — Create a new custom dimension

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "gtm-ga4": {
    "command": "npx",
    "args": ["-y","mcp-gtm-ga4"],
    "env": {
      "GOOGLE_APPLICATION_CREDENTIALS": "",
      "GTM_ACCOUNT_ID": "",
      "GTM_CONTAINER_ID": "",
      "GA4_PROPERTY_ID": "",
      "GTM_SANDBOX_WORKSPACE_ID": "",
      "MCP_SERVER_NAME": ""
    }
  }
}
```

**Requires environment variables:** `GOOGLE_APPLICATION_CREDENTIALS`, `GTM_ACCOUNT_ID`, `GTM_CONTAINER_ID`, `GA4_PROPERTY_ID`, `GTM_SANDBOX_WORKSPACE_ID`, `MCP_SERVER_NAME` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## 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.

_Full upstream README: https://allmcps.com/mcp/gtm-ga4/readme_

