Web Analytics & Tracking MCP Server
Enables sending server-side events to Google Analytics 4 via Measurement Protocol, validating event payloads against GA4 e-commerce schemas, and generating gtag.js tracking snippets.
Provides DataLayer schema validation for GTM and generates GTM dataLayer.push tracking code snippets.
Audits tracking event payloads for Meta Conversions API (CAPI), scoring readiness and providing recommendations.
Generates React tracking hooks for integrating analytics events.
Click on "Deploy 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., "@Web Analytics & Tracking MCP Server Validate my dataLayer push for purchase against the GA4 e-commerce schema"
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.
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.
π Features
π― DataLayer Schema Validator: Automatically validates GTM
dataLayer.pushobjects 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, GA4gtag.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 build3. 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 toolsaudit_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
Scored across 4 tools
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).
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.
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.
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
Related MCP Connectors
Hosted MCP server for marketing analytics: plan tracking, draft GTM tags, audit tags. Free in beta
Hosted MCP server for GA4, Google Ads and Search Console. Google OAuth, nothing to install.
Hosted Google Tag Manager MCP server, with each action switched on or off per account.
Hosted Google Analytics 4 MCP server, with each action switched on or off per account.
Related MCP Servers
- AlicenseBqualityBmaintenanceProduction-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 audits203663 npm3MIT
- AlicenseAqualityBmaintenanceMCP server for Google Tag Manager and GA4, enabling tag management, consent auditing, workspace versioning, and analytics reporting through natural language.11345 npm3MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for Google Tag Manager and Google Ads, enabling AI agents to audit, fix, and manage GTM containers and Google Ads campaigns programmatically.106 npmMIT
- AlicenseBqualityCmaintenanceMCP 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.40MIT