Labsco
neep305 logo

Google Tag Manager

β˜… 6

from neep305

Integrates Google Tag Manager to automate GTM configuration and component creation through natural language prompts.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

Google Tag Manager MCP Server

A Model Context Protocol (MCP) server that integrates Google Tag Manager with Claude, enabling automated GTM configuration and component creation through natural language prompts.

Features

  • GTM API Integration: Full Google Tag Manager API integration for creating and managing tags, triggers, and variables
  • Component Templates: Pre-built templates for common tracking scenarios (GA4, Facebook Pixel, conversion tracking)
  • Workflow Automation: Complete workflow creation for different site types (ecommerce, lead generation, content sites)
  • Claude Integration: Natural language interface for GTM configuration through Claude

Available Tools

Basic GTM Operations

  • create_gtm_tag: Create individual GTM tags
  • create_gtm_trigger: Create GTM triggers
  • create_gtm_variable: Create GTM variables
  • list_gtm_containers: List all containers for an account
  • get_gtm_container: Get container details
  • publish_gtm_version: Publish a container version

Workflow Tools

  • create_ga4_setup: Complete Google Analytics 4 setup with config tag and common events
  • create_facebook_pixel_setup: Facebook Pixel tracking setup
  • create_form_tracking: Form submission tracking setup
  • generate_gtm_workflow: Generate complete workflows for different site types

Workflow Types

The generate_gtm_workflow tool supports three main workflow types:

  • ecommerce: Enhanced ecommerce tracking with purchase, cart, and product interaction events
  • lead_generation: Form submissions, CTA clicks, and conversion tracking
  • content_site: Content engagement, newsletter signups, and social sharing

Authentication

On first run, the server will open a browser window for OAuth authentication. Grant the necessary permissions to access your GTM account. The authentication token will be saved for future use.

File Structure

mcp-for-gtm/
β”œβ”€β”€ server.py              # Main MCP server
β”œβ”€β”€ gtm_client.py          # GTM API client
β”œβ”€β”€ gtm_components.py      # Component templates and workflow builder
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ config.json           # MCP server configuration
β”œβ”€β”€ credentials.json      # Google OAuth credentials (you provide)
β”œβ”€β”€ token.json           # Generated auth token (auto-created)
└── README.md           # This file

Development

Running Tests

# Using uv
uv run python test_server.py

# Or directly with python
python test_server.py

Running the Server

# Using the convenience script
./run_server.sh

# Or manually with uv
uv run python server.py

# Or with system python
python server.py

Development Dependencies

The project includes development dependencies for code quality:

# Format code with black
uv run black .

# Check with flake8
uv run flake8 .

# Type checking with mypy
uv run mypy .

# Run tests with pytest
uv run pytest

Contributing

Feel free to submit issues and enhancement requests!