Google Tag Manager MCP
Provides a cross-MCP bridge for bidirectional reconciliation with the Google Ads API, including auditing conversion tracking and attribution.
Provides tools for auditing, governing, staging, and safely publishing Google Tag Manager containers, including tags, triggers, variables, workspaces, versions, permissions, custom templates, and rollback.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
English · Español
Google Tag Manager MCP (google-tag-manager-mcp)
The Forensic Auditing, Governance & Safe Staging Operating System for Google Tag Manager (Model Context Protocol).
Stop flying blind with passive AI tools that hallucinate live changes. Audit, govern, stage, and defensively protect your Google Tag Manager containers and advertising attribution at an executive level.
Quick Start · Two-Phase Safety · The 4 Attribution Killers · Tool Catalog · Dynamic Profiles · Legal Notice
Guaranteed Production Safety & Performance: Every mutation across tags, triggers, templates, or variables strictly adheres to Two-Phase Commit (edits occur inside an isolated staging workspace with an in-memory Mutation-Aware Cache reducing API calls by 80%). No AI agent can publish live containers or trigger breaking changes to production traffic without your explicit in-chat authorization (confirmed=True).
How to Use in 60 Seconds (Zero Coding)
You don't need to write code or manage local development environments. If you use Claude Desktop, Antigravity, or ChatGPT Desktop, simply register the server configuration and copy the master prompt.
Step 1: Connect the Server to your AI Client
Open your AI application's configuration file (e.g., claude_desktop_config.json for Claude Desktop) and add this block inside "mcpServers":
{
"mcpServers": {
"google-tag-manager": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/eddvasquez/google-tag-manager-mcp",
"google-tag-manager-mcp"
],
"env": {
"GTM_ACCOUNT_ID": "your_gtm_account_id",
"GTM_CONTAINER_ID": "your_gtm_container_id",
"GTM_OAUTH_CLIENT_ID": "your_client_id",
"GTM_OAUTH_CLIENT_SECRET": "your_client_secret",
"GTM_OAUTH_REFRESH_TOKEN": "your_refresh_token"
}
}
}
}Local clone alternative: If you cloned this repository locally, run "command": "uv" and "args": ["--directory", "path/to/google-tag-manager-mcp", "run", "google-tag-manager-mcp"].
Step 2: Copy & Paste this Master Prompt into your AI Chat
Act as my World-Class Measurement Architect & Senior Google Tag Manager Consultant.
You have access to the 'google-tag-manager-mcp' server.
We operate strictly under enterprise measurement and high-performance advertising attribution standards:
1. NON-NEGOTIABLE RULE: Never publish live containers without staging changes in an isolated workspace and presenting the detailed diff for my explicit authorization (confirmed=True).
2. Begin by executing Phase 1: Forensic Ad Tracking Alignment Audit on my container (Account ID: [YOUR_ACCOUNT_ID], Container ID: [YOUR_CONTAINER_ID]).
3. Identify if any Conversion Linker tags are missing or paused, inspect Consent Mode v2 status across all marketing tags, and detect any duplicate conversion risks before proposing new tags.Related MCP server: safe-runbook-mcp
Your Live Site is Safe: Two-Phase Commit Security
The single biggest fear of a Media Buyer or Webmaster when connecting an AI to Google Tag Manager is: What happens if the model hallucinates an invalid script, deletes an essential trigger, or breaks production tracking for thousands of visitors?
This system incorporates Mandatory Transactional Safeguards:
Isolated Workspace Staging: When the AI prepares an action (creating a tag, tweaking triggers, adding Data Layer variables), mutations are executed inside a designated staging workspace. Live production traffic (
live) is 100% untouched.Visual Diff & Integrity Report: The AI inspects dependencies and presents the exact proposed diff in chat.
Immutable Human Authorization Gate: Only when you reply with explicit confirmation does the system execute version creation and live deployment (
confirmed=True).Instant 1-Click Rollback: In case of any unforeseen edge-case, the server provides an emergency rollback tool (
gtm_release_quick_rollback) to restore the prior known-good version in seconds.
sequenceDiagram
autonumber
actor MB as Media Buyer / Engineer (User)
participant IA as AI Coding Agent (Claude / Antigravity / ChatGPT)
participant MCP as MCP Server (GTM Engine)
participant GTM as Google Tag Manager API v2 (Live Site)
MB->>IA: "Create a GA4 'generate_lead' event tag"
Note over IA,MCP: PHASE 1: ISOLATED WORKSPACE STAGING (ZERO LIVE RISK)
IA->>MCP: gtm_staging_prepare_ga4_event (Workspace: Staging)
MCP->>GTM: Creates tag in isolated workspace (Draft)
GTM-->>MCP: Staging confirmed (Live container untouched)
MCP-->>IA: Returns StagingProposal (Diff + Audit summary)
IA->>MB: Displays report: "Tag staged in Workspace #2. Ready to version & publish?"
alt User Authorizes Deployment
MB->>IA: "Looks great, publish it"
IA->>MCP: gtm_release_publish_version (confirmed=True)
MCP->>GTM: Freezes version & publishes to LIVE traffic
GTM-->>MCP: Live deployment confirmed
MCP-->>IA: ReleaseResult (Status: PUBLISHED)
IA->>MB: "Version 7 published successfully to production."
else User Rejects or Corrects
MB->>IA: "Wait, change the trigger to form submission"
IA->>MCP: gtm_staging_prepare_tag (Updates draft in staging workspace)
endThe Four Silent Tracking Killers Destroying your ROAS
The Missing Conversion Linker (
gclidw): Without a Conversion Linker on All Pages, Safari ITP and iOS 14.5+ purge the Google Click Identifier (gclid), blinding Google Ads to downstream conversions and degrading Smart Bidding into random guessing.Consent Mode v2 Blindness: Unconfigured tags (
NOT_SET) in EEA or global compliant setups fail to transmit consent signals (ad_user_data,ad_personalization), preventing Google Ads from training audiences and optimizing bids.Transaction ID Omission (Algorithmic Poisoning): Lead or Purchase conversion tags firing without a deduplication key (
orderId/lead_id) trigger double-counting on page refreshes, artificially distorting CPA and burning ad budgets on phantom conversions.Custom HTML
document.writeDOM Crashes: Legacy scripts invoking synchronousdocument.writeget blocked by modern browsers or cause partial rendering freezes on mobile devices.
The 81-Tool Advertising & Measurement Catalog
Module | Tool Name | Description |
Discovery |
| Lists all accessible Google Tag Manager accounts. |
Discovery |
| Lists containers under an account (Web, Server, Mobile). |
Discovery |
| Retrieves official or generated |
Discovery |
| Lists development branches and default workspaces. |
Discovery |
| Full inventory of tags with type, status, and triggers. |
Discovery |
| Full inventory of triggers with filters and event conditions. |
Discovery |
| Lists all user-defined and Data Layer variables. |
Discovery |
| Historical version headers, changelogs, and authors. |
Discovery |
| Lists all account-level and container-level user permissions and roles. |
Discovery |
| Lists custom templates and Community Gallery templates in workspace. |
Discovery |
| Lists GTM 360 zones in workspace. |
Discovery |
| Lists Google Tag (gtag) centralized parameter configurations. |
Intelligence |
| Anti-Bot & Click Fraud Shield: Audits primary conversion tags for lack of honeypots or bot gating. |
Intelligence |
| Geofenced Consent Mode v2: Catches universal 'denied' blackouts on non-EEA traffic (US/LATAM). |
Intelligence |
| Value-Based Bidding (VBB) Hierarchy: Audits non-zero weighting for macro vs micro actions. |
Intelligence |
| Enhanced Conversions Normalizer: Lints international E.164 phone formatting and lowercase email regex. |
Intelligence |
| Core Web Vitals (LCP/INP) Analyzer: Flags render-blocking tags firing on All Pages instead of Window Loaded. |
Intelligence |
| Custom Template Sandbox Linter: Detects insecure HTTP endpoints and excessive sandboxed JS APIs. |
Intelligence |
| Cross-MCP Bridge: Bi-directional reconciliation between Google Ads API conversions and GTM tags (interoperable with |
Intelligence |
| Audits agency access, rogue account admins, and enforces least privilege. |
Intelligence |
| Audits GTM 360 zones for type restriction whitelists and script security. |
Intelligence |
| Measurement Drift Detector: Compares live active container against baseline to catch untracked changes. |
Intelligence |
| Cross-Network Deduplication Matrix: Verifies exact orderId/eventID parity across Google, Meta, and TikTok. |
Intelligence |
| Simulates Consent Mode v2 AI modeled conversions volume and recovered revenue vs basic blackout. |
Intelligence |
| Holding Period & Learning Phase Guard: Flags CPA volatility risks when modifying primary bidding tags. |
Intelligence |
| Server-Side sGTM to BigQuery Schema Linter: Verifies event_timestamp, user_pseudo_id, and items arrays. |
Intelligence |
| Executive Attribution Health & ROAS Leakage Scorecard: 0-100 score with $ wasted spend model. |
Intelligence |
| CI/CM DataLayer Linter: validates variables against GA4 Ecommerce, Lead Gen, and Cart-Data contracts. |
Intelligence |
| Audits hidden input injection & postMessage listeners for CRM attribution (HubSpot, Typeform, GHL). |
Intelligence |
| Verifies |
Intelligence |
| Cross-MCP Bridge: Reconcile Google Ads conversion actions against GTM 'awct' tags (interoperable with |
Intelligence |
| Validates CMP Consent Initialization timing, defaults, and race conditions. |
Intelligence |
| Sizing & Cloud Run Cost Calculator for sGTM instances, egress, and GCP monthly bill. |
Intelligence |
| Forensic audit of Conversion Linker, cross-domain, and Google Ads setup. |
Intelligence |
| Detects micro-triggers (scroll, timers, visibility) attached to primary Google Ads conversion tags. |
Intelligence |
| Audits Enhanced Conversions formatting (E.164 phone, sanitized email). |
Intelligence |
| Audits real-time contact data capture on form submits for offline matching. |
Intelligence |
| Validates dynamic conversion values and ISO-4217 currencies for tROAS. |
Intelligence |
| Evaluates net margin tracking and tiered lead valuations for Value-Based Bidding. |
Intelligence |
| Audits tag consent settings ( |
Intelligence |
| Classifies Basic vs Advanced Consent Mode and estimates AI signal recovery. |
Intelligence |
| Audits Safari ITP defenses, first-party cookie longevity, and iOS click IDs. |
Intelligence |
| Detects tag collisions and missing |
Intelligence |
| Inspects transaction IDs, deduplication keys, and Enhanced Conversions. |
Intelligence |
| Validates Measurement IDs and canonical |
Intelligence |
| Cross-validates Custom Event triggers against DataLayer variables. |
Intelligence |
| Detects orphaned triggers, orphaned variables, and legacy paused tags. |
Intelligence |
| Scans Custom HTML for |
Intelligence |
| Audits Server Containers (sGTM), client templates, and FPID preservation. |
Intelligence |
| Inspects sGTM transformations for PII anonymization and client proxy setups. |
Staging |
| Scaffolds Honeypot variables & Turnstile blocking triggers on primary conversion tags. |
Staging |
| Scaffolds Geo-Fenced Consent Mode v2 (EEA 'denied' vs non-EEA 'granted'). |
Staging |
| Scaffolds 90-day 1st-party cookie & localStorage Attribution Vault for offline CRM imports. |
Staging |
| Generates validated Terraform HCL for sGTM Cloud Run provisioning with custom domains. |
Staging |
| Official Community Template Gallery Importer: 1-click import with explicit permission acknowledgement. |
Staging |
| 1-Click New Customer Acquisition (NCA) & pLTV Scaffolding: purchase tag with NCA multipliers. |
Staging |
| CI/CD Container Importer: staged merge of canonical GTM JSON blueprints with conflict resolution. |
Staging |
| 1-Click Cart-Data Scaffolding: purchase tag with product items and line margins for tROAS profit bidding. |
Staging |
| Server-Side sGTM simulation: validates HTTP client parsing, PII redactions, and outbound dispatch. |
Staging |
| In-memory tag/trigger simulation without browser: inspects fired tags and extracts ad payloads. |
Staging |
| 1-Click Media Buyer Pack: Persist gclid/wbraid, inject hidden inputs, and decorate WhatsApp links. |
Staging |
| 1-Click complete Google Ads conversion triad (DLV, Trigger, Tag, Deduplication). |
Staging |
| Drafts or updates a tag in an isolated workspace. |
Staging |
| Drafts or updates a trigger with logic filters in workspace. |
Staging |
| Drafts or updates Data Layer variables in workspace. |
Staging |
| 1-click scaffolding of an enterprise Conversion Linker tag. |
Staging |
| Scaffolds Consent Mode v2 default tag on Consent Initialization. |
Staging |
| Scaffolds standard GA4 recommended events with consent defaults. |
Staging |
| Batch enables essential ad tracking variables (pageUrl, clickId, formId). |
Staging |
| Automatically structures enterprise folders (Core, Ads, GA4, Meta, Utility). |
Staging |
| Generates Tag Assistant preview environment without publishing. |
Staging |
| Synchronizes staging workspace with latest container version, detecting conflicts. |
Staging |
| Computes unversioned entity diff against the live container. |
Staging |
| Exports entire staging workspace as a portable canonical GTM JSON blueprint. |
Staging |
| Creates an isolated ephemeral staging workspace. |
Staging |
| Deletes a staging workspace after testing. |
Release |
| Freezes workspace into an immutable release version. |
Release |
| Protected live deployment (blocks without |
Release |
| Instant emergency rollback to previous known-good version. |
Release |
| Lists environments configured for container (Live, QA, Dev). |
Release |
| Retrieves metadata of currently active version in production. |
Context Window Optimization & Dynamic Tool Profiles
To keep AI context windows lean and token-efficient across Claude Desktop or ChatGPT, google-tag-manager-mcp supports dynamic profiles via the GTM_MCP_PROFILE environment variable or tools_config.yaml:
Profile | Active Tools | Use Case |
| 81 Tools + 2 Resources | Full enterprise operations (audit, staging, release). |
| 46 Tools | Forensic audits, Scorecard, and Smart Bidding intelligence without mutations. |
| 76 Tools | Complete audits, Scorecard, simulation, and 1-click scaffolding without live production release tools. |
| 44 Tools | Discovery, manual staging, container import, template management, IaC, and release management. |
| 12 Tools | Read-only discovery and inventory lookup. |
Configure in your client settings:
"env": {
"GTM_MCP_PROFILE": "media_buyer"
}Legal Notice, Trademark & Disclaimer
Google Tag Manager, Google Ads, Google Analytics, and GA4 are registered trademarks of Google LLC.
This software is an independent open-source Model Context Protocol server developed to provide programmatic interoperability with Google Tag Manager API v2.
It is not officially endorsed, affiliated with, or sponsored by Google LLC.
Safety Guarantee: Users retain full control over live publications through the mandatory Two-Phase Safety confirmation protocol.
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
Versioned artifact review for people and AI agents, with contextual comments and human control.
Zendesk configuration management for AI agents: propose, review, apply and roll back changes.
Remote MCP for AI Studio Android release gate MCP, structured receipts, audit logs, and reviewer-rea
Runtime AI governance: decision gates, human approval, hash-chained audit, compliance mapping.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceLocal governance layer for AI-assisted development, providing human authorization gates, policy enforcement, change approval workflow, and rollback capabilities through a universal MCP server.MIT
- AlicenseAqualityBmaintenanceEnables AI agents to safely inspect and execute version-controlled operational runbooks with policy checks, dry-run planning, and out-of-band approvals.3MIT
- FlicenseNot gradedqualityBmaintenanceEnables lifecycle-first governance for Edge AI fleets via MCP tools for approval requests, gate evaluation, and manual hold, ensuring deterministic deployment decisions with two-person approval, attestation, and safe rollback.4-
- AlicenseNot gradedqualityBmaintenanceEnables controlled development and staging operations through audited tools for project status, testing, services, databases, deployments, logs, backups, and rollbacks.29 PyPIMIT