Skip to main content
Glama
gtm-tag-architect

gtm-tag-architect

gtm-tag-architect

A public, production-ready plugin for Google Antigravity, Claude Code, and Cursor that connects to Google Tag Manager via the Model Context Protocol (MCP).

It provides an interactive /setup command that interviews developers and marketers about their site, diagnoses container defects (duplicates, missing triggers, Consent Mode v2 violations), and generates optimized tracking taxonomies and dataLayer contracts for both TypeScript (Next.js/React) and PHP (WordPress/Laravel/Symfony).


Features

  • /setup Interactive Command: Guides you through a 3-stage interview and audit workflow.

  • Deep Container Diagnostics: Audits duplicate GA4/Meta tags, orphaned triggers, unconsented marketing pixels, and render-blocking scripts.

  • Automated Remediation: Deduplicates tags and enforces Google Consent Mode v2 (or provides an explicit opt-out bypass for internal/US tools).

  • Multi-Framework dataLayer Contracts: Generates typed TypeScript definitions (dataLayer.d.ts) or native PHP classes (GtmDataLayer.php) for WordPress, Laravel, Symfony, and custom backends.

  • Industry Tracking Matrices: Pre-built taxonomy runbooks for E-Commerce, SaaS/PLG, B2B Lead Gen, and Technical Portfolios.

  • Dual-Mode MCP Server: Runs live against Google Tag Manager REST API v2 or audits local exported container JSON files offline (Zero API setup).


Related MCP server: mcp-gtm-ga4

Documentation & Guides


Quickstart: How to Connect via MCP

Mode 1: Offline JSON Export (Zero API Setup)

  1. In GTM, go to Admin > Export Container and save as container.json.

  2. Configure your MCP client to point to the file via GTM_OFFLINE_CONTAINER_PATH.

Mode 2: Live Google Tag Manager API

  1. Enable Tag Manager API in Google Cloud Console.

  2. Create a Service Account, download the JSON key, and add the service account email in GTM Admin > User Management with Read or Edit permissions.

  3. Set GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json.

(See the Complete Setup Guide for step-by-step instructions with screenshots and permission configurations.)


MCP Client Configuration

For Google Antigravity

Clone or place this repository into your workspace or global customizations directory:

# In your project's .agents/plugins/ or ~/.gemini/config/plugins/
git clone https://github.com/jarnielcataluna/gtm-tag-architect.git

Antigravity will automatically discover the plugin, expose the /setup slash command, and register the MCP server defined in mcp_config.json.

For Claude Code / Claude Desktop

Register the server in your claude_desktop_config.json or project MCP settings:

{
  "mcpServers": {
    "gtm-tag-architect": {
      "command": "node",
      "args": ["/path/to/gtm-tag-architect/bin/gtm-mcp.js"],
      "env": {
        "GTM_OFFLINE_CONTAINER_PATH": "./fixtures/sample-ecommerce-container.json"
      }
    }
  }
}

For Cursor IDE

  1. Open Cursor Settings > Features > MCP Servers.

  2. Click + Add New MCP Server.

  3. Name: gtm-tag-architect | Type: command | Command: node /path/to/gtm-tag-architect/bin/gtm-mcp.js


Usage

Run the /setup Command

Inside Antigravity or Claude Code:

/setup

The agent will interview you about:

  1. Site Type & Industry: E-Commerce, SaaS, Lead Gen, Content, Portfolio

  2. Framework: Next.js/React, WordPress, Laravel, Symfony, or Vanilla PHP

  3. Required Pixels: GA4, Meta, LinkedIn, Google Ads, PostHog

  4. Privacy Strategy: Enforce Consent Mode v2 (Strict GDPR) vs. Opt-Out / Direct Firing

It then performs a diagnostic audit and presents you with an action menu to fix defects, apply consent rules, and export clean dataLayer contracts.


Testing & Local Audit

You can run the offline diagnostic test harness against the included test fixture:

npm install
npm run audit-fixture

License

MIT

Available Tools

5 tools
gtm_add_tag_recipeB

Adds a pre-configured tag recipe (GA4 Core, Meta Pixel, PostHog, or LinkedIn) to the container workspace.

Inputs: recipe (required), pixelId, containerPath, measurementId.

gtm_audit_containerA

Runs a deep diagnostic audit on a Google Tag Manager container. Identifies duplicate tags, missing triggers, unconsented tracking (Consent Mode v2), and heavy blocking scripts.

Inputs: containerPath.

gtm_deduplicate_tagsA

Deduplicates GA4 configuration and Meta Pixel tags in the GTM container, consolidating firing triggers and pruning duplicate base tags.

Inputs: containerPath.

gtm_generate_datalayer_typesA

Generates production TypeScript type definitions and helper push functions for developers (E-commerce, SaaS, or Lead Gen).

Inputs: industry (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 5 tools

    Disambiguation4/5

    Each tool targets a distinct action in the GTM workflow—audit, deduplicate, apply consent, add recipe, generate types—so an agent can usually pick the right one. Minor overlap exists where audit surfaces duplicates and consent gaps that deduplicate and apply_consent_mode then fix, but the strong action verbs keep the boundaries clear.

    Naming Consistency5/5

    All tool names follow the identical `gtm_<verb>_<object>` snake_case pattern with perfect consistency. The `gtm_` prefix scopes everything to the domain, and every verb is a single lowercase action word.

    Tool Count5/5

    Five tools is a well-scoped surface for a GTM tag-management assistant. Each tool addresses a distinct stage of the tag lifecycle—audit, cleanup, compliance, templating, and developer handoff—without feature bloat.

    Completeness4/5

    The core architecture workflow is well covered: audit, deduplicate, configure consent, add standard tags, and generate TypeScript datalayer helpers. Publication/preview submission and tag removal are missing, so agents may need workarounds, but the primary setup path is fully covered.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      MCP server for Google Tag Manager and GA4, enabling tag management, consent auditing, workspace versioning, and analytics reporting through natural language.
      11
      345 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      MCP server for Google Tag Manager API v2, enabling programmatic management of accounts, containers, workspaces, tags, triggers, variables, and version workflows.
      40 npm
      15
      MIT
    • A
      license
      A
      quality
      F
      maintenance
      An MCP server for the Google Tag Manager API v2 that enables AI assistants to query GTM accounts, containers, tags, triggers, variables, and unpublished changes.
      24
      1
      Apache 2.0