mcp-gtm-ga4
Provides tools for managing Google Tag Manager workspaces, tags, triggers, variables, consent auditing, and container versioning.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-gtm-ga4audit consent compliance for all tags"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-gtm-ga4
MCP server for Google Tag Manager and GA4 -- tag management, consent auditing, workspace versioning, and analytics reporting via Claude.
Features
14 tools spanning GTM workspace management (tags, triggers, variables), consent compliance auditing, workspace preview/versioning, and GA4 reporting
Sandbox safety -- all write operations verify they target the resolved workspace, refusing to write to non-sandbox workspaces
Multi-client support -- configure per-client via environment variables
Auto-detects Default Workspace ID -- no need to manually specify workspace IDs unless using a custom sandbox
Related MCP server: Google Analytics MCP Server
Installation
npm install mcp-gtm-ga4Or clone and build:
git clone https://github.com/mharnett/mcp-gtm-ga4.git
cd mcp-gtm-ga4
npm install
npm run buildConfiguration
Security: Never share your .mcp.json file or commit it to git -- it may contain API credentials. Add .mcp.json to your .gitignore.
All configuration is via environment variables. No config.json file is needed.
Variable | Required | Description |
| Yes | Path to a GCP service account JSON key file |
| Yes | GTM account ID |
| Yes | GTM container ID |
| Yes | GA4 property ID |
| No | Override workspace ID (auto-detects Default Workspace if omitted) |
| No | Server name (defaults to package name |
See config.example.json for a reference template.
Usage
Claude Code (.mcp.json)
{
"mcpServers": {
"gtm-ga4": {
"command": "node",
"args": ["/path/to/mcp-gtm-ga4/dist/index.js"],
"env": {
"GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json",
"GTM_ACCOUNT_ID": "1234567890",
"GTM_CONTAINER_ID": "9876543",
"GA4_PROPERTY_ID": "331956119"
}
}
}
}npx
GTM_ACCOUNT_ID=1234567890 \
GTM_CONTAINER_ID=9876543 \
GA4_PROPERTY_ID=331956119 \
GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa.json \
npx mcp-gtm-ga4Claude Desktop: Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows).
Safety
Workspace sandbox protection
All write operations (gtm_update_tag, gtm_create_tag, gtm_preview, gtm_create_version) verify they target the resolved workspace before executing. If a request attempts to write to a different workspace, the server returns a SafetyError and blocks the operation.
This prevents accidental production changes when the MCP server is configured against a sandbox workspace.
Tools
GTM Tags
Tool | Description |
| List all tags in the workspace with consent status and firing triggers |
| Get full tag configuration by tag ID |
| Update an existing tag (merge patch via JSON) |
| Create a new tag from a JSON definition |
GTM Structure
Tool | Description |
| List all triggers (ID, name, type) |
| List all variables (ID, name, type) |
GTM Consent
Tool | Description |
| Audit all tags for consent configuration compliance |
GTM Workspace
Tool | Description |
| Generate a quick preview of the current workspace |
| Create a new container version from the workspace |
GA4 Reports
Tool | Description |
| Run a GA4 report with dimensions, metrics, date range, and filters |
| Run a GA4 realtime report (last 30 minutes) |
GA4 Admin
Tool | Description |
| List all custom dimensions for the property |
| Create a new custom dimension |
Architecture
GTM API:
googleapis(Tag Manager v2)GA4 Data:
@google-analytics/data(BetaAnalyticsDataClient)GA4 Admin:
@google-analytics/admin(AnalyticsAdminServiceClient)Resilience:
cockatiel(retry, circuit breaker, timeout policies)Logging:
pinowithpino-prettyTransport: MCP SDK stdio transport
License
MIT
Author
Built by Mark Harnett / drak-marketing
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mharnett/mcp-gtm-ga4'
If you have feedback or need assistance with the MCP directory API, please join our Discord server