Skip to main content
Glama
Web Analytics & Tracking MCP Server

Web Analytics & Tracking MCP Server

Web Analytics & Tracking MCP Server

A production-ready Model Context Protocol (MCP) server for Google Tag Manager (GTM), Google Analytics 4 (GA4) Measurement Protocol, DataLayer schema validation, Meta CAPI auditing, and tracking code snippet generation.

Build Status TypeScript License


πŸ“Œ Features

  • 🎯 DataLayer Schema Validator: Automatically validates GTM dataLayer.push objects against GA4 e-commerce schemas (purchase, add_to_cart, lead, etc.).

  • πŸš€ GA4 Measurement Protocol Event Transmitter: Transmits server-side events directly to Google Analytics 4 via Measurement Protocol API.

  • πŸ› οΈ Tracking Code Snippet Generator: Generates production-ready code snippets for GTM window.dataLayer.push, GA4 gtag.js, and React tracking hooks.

  • πŸ“Š Tracking Quality & EMQ Auditor: Audits tracking event payloads for GA4 and Meta Conversions API (CAPI), scoring readiness from 0-100 and providing recommendations.

  • πŸ“‘ Built-in Specification Resource: Exposes static GA4 e-commerce standard schemas as an MCP resource (ga4://spec/ecommerce).


Related MCP server: mcp-gtm-ga4

πŸ› οΈ Quick Start

1. Prerequisites

  • Node.js: v18.0.0 or higher

  • npm: v9.0.0 or higher

2. Installation & Build

# Clone repository
git clone https://github.com/webanalyticsprobd-maker/tracking-mcp-server.git
cd tracking-mcp-server

# Install dependencies
npm install

# Compile TypeScript
npm run build

3. Environment Setup (Optional)

Copy .env.example to .env and fill in your GA4 credentials if you plan to send live server-side Measurement Protocol events:

GA4_MEASUREMENT_ID=G-XXXXXXXXXX
GA4_API_SECRET=your_ga4_api_secret_here

βš™οΈ How to Connect to MCP Clients

Cursor IDE Configuration

Add the following snippet to your Cursor MCP Tools settings or .cursor/mcp.json:

{
  "mcpServers": {
    "tracking-analytics-server": {
      "command": "node",
      "args": ["C:/path/to/tracking-mcp-server/dist/index.js"],
      "env": {
        "GA4_MEASUREMENT_ID": "G-XXXXXXXXXX",
        "GA4_API_SECRET": "your_api_secret"
      }
    }
  }
}

Claude Desktop Configuration

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "tracking-analytics-server": {
      "command": "node",
      "args": ["C:/path/to/tracking-mcp-server/dist/index.js"]
    }
  }
}

πŸ“„ License

Licensed under the MIT License.

Available Tools

4 tools
audit_tracking_readinessA

Audits a tracking event payload against GA4 or Meta CAPI readiness standards and returns an EMQ/Quality score (0-100) with actionable recommendations.

Inputs: payload (required), platform (required).

generate_tracking_code_snippetA

Generates production-ready tracking code snippets for GTM dataLayer.push, GA4 gtag.js, or React custom hook.

Inputs: platform (required), eventName (required), parameters (required).

send_ga4_measurement_protocol_eventB

Transmits a server-side analytics event to Google Analytics 4 via Measurement Protocol API.

Inputs: clientId (required), eventName (required), apiSecret, eventParams, +1 more.

validate_datalayer_eventB

Validates a GTM DataLayer event payload against GA4 & E-commerce schema standards to detect missing parameters or invalid types.

Inputs: eventPayload (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 4 tools

    Disambiguation4/5

    The tools are mostly distinct: generating, validating, auditing, and sending events each serve clear purposes. However, 'audit_tracking_readiness' and 'validate_datalayer_event' both involve checking payloads, which could cause some confusion despite their different scopes (readiness/score vs schema validation).

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern in snake_case: audit, generate, validate, and send. The naming is predictable and clearly indicates the action being performed.

    Tool Count5/5

    With only 4 tools, the server is tightly scoped to its purpose of web analytics tracking. Each tool covers a distinct aspect (generation, validation, auditing, server-side sending), so the count feels appropriate without being too thin or heavy.

    Completeness4/5

    The tool surface covers the primary workflow for implementing and verifying tracking: generate code, validate payloads, audit readiness, and send events. Minor gaps exist, such as no direct tool for fetching schemas or managing tracking configuration, but these are not critical for the core use case.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      Production-grade MCP server for the Google Tag Manager API v2 with read-only GA4 (Admin + Data API) tooling. 107 tools covering the full GTM surface, including server-side containers. Ships read-only: writes, publishes, and deletes are each gated behind separate opt-in flags, every mutation requires per-call confirmation, and a dry-run mode simulates changes. Includes container audits
      203
      663 npm
      3
      MIT
    • 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 and Google Ads, enabling AI agents to audit, fix, and manage GTM containers and Google Ads campaigns programmatically.
      106 npm
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      MCP server for Google Analytics 4 and Google Tag Manager with read and write access, providing 40 tools to manage GA4 reports, audiences, and GTM tags, triggers, and variables via natural language.
      40
      MIT