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 "Install 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 ServerValidate 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.
| Name | Required | Description | Default |
|---|---|---|---|
| payload | Yes | Event object payload to audit | |
| platform | Yes | Platform to audit event against |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description discloses the return value (score 0-100, recommendations) and the read-only nature implied by 'Audits'. However, with no annotations provided, it does not explicitly state that no data is modified or whether external calls are made, leaving some behavioral aspects opaque.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, well-structured sentence that front-loads the verb 'Audits' and provides key details without unnecessary fluff. Every word contributes to the meaning, making it highly concise and readable.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity with a nested payload and no output schema, the description adequately explains the output (score and recommendations) and the target platforms. It lacks details on what constitutes 'readiness', but the overall purpose and result are sufficiently clear for an agent to invoke it.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Both parameters have descriptions in the schema (payload and platform), and the schema's coverage is 100%. The description adds little beyond the schema, only citing GA4/Meta CAPI readiness which aligns with the platform enum, so it does not significantly enhance parameter understanding.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's action ('Audits a tracking event payload'), the target standards ('GA4 or Meta CAPI readiness'), and the output ('EMQ/Quality score with recommendations'). This distinguishes it from siblings like validate_datalayer_event (validation) and send_ga4_measurement_protocol_event (sending).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives. It does not mention any exclusions, prerequisites, or comparison to sibling tools like validate_datalayer_event, leaving the agent without clear direction on selecting it.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
generate_tracking_code_snippetA
Generates production-ready tracking code snippets for GTM dataLayer.push, GA4 gtag.js, or React custom hook.
| Name | Required | Description | Default |
|---|---|---|---|
| platform | Yes | Target platform format for code generation | |
| eventName | Yes | Name of event (e.g. 'add_to_cart', 'lead') | |
| parameters | Yes | Event parameters key-value object |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states that it generates 'production-ready' snippets, but does not disclose side effects (e.g., whether it modifies anything), authentication requirements, or output format. This is a significant gap for a tool with no annotation support.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence that front-loads the verb and resource, and lists the key platform options. Every word contributes value, with no filler or repetition.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (3 required parameters, nested parameters object) and no output schema, the description is adequate but gaps remain. It does not explain the output format of the generated snippet or clarify when to use this tool instead of related siblings. The schema covers inputs well, but the absence of annotations and output schema leaves some ambiguity about behavior and results.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema provides 100% coverage of parameters, including descriptions and an enum for platform. The description redundantly lists the platforms in prose ('GTM dataLayer.push, GA4 gtag.js, React custom hook'), but this adds little beyond the schema's enum. Baseline 3 is appropriate given the high schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb 'Generates' with a clear resource ('tracking code snippets') and enumerates the target platforms (GTM dataLayer.push, GA4 gtag.js, React custom hook). This clearly distinguishes it from sibling tools focused on auditing, validating, or sending events.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies when to use the tool (when you need tracking code snippets for these platforms), but it does not provide explicit guidance on when to choose this tool over siblings like validate_datalayer_event or send_ga4_measurement_protocol_event. There are no exclusions or alternative recommendations.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
send_ga4_measurement_protocol_eventB
Transmits a server-side analytics event to Google Analytics 4 via Measurement Protocol API.
| Name | Required | Description | Default |
|---|---|---|---|
| clientId | Yes | GA4 Client ID (e.g. '123456789.987654321') | |
| apiSecret | No | GA4 API Secret override (default read from ENV) | |
| eventName | Yes | Name of the event to track (e.g. 'purchase', 'page_view') | |
| eventParams | No | Arbitrary event parameters object | |
| measurementId | No | GA4 Measurement ID override (default read from ENV) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must disclose behavioral traits. It only states the action and destination, omitting important details such as authentication requirements (e.g., environment variables for API secret/measurement ID), rate limits, error handling, or whether the operation is idempotent. This is a significant gap for a network-sending operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, direct sentence with no redundant words. It front-loads the core action and destination, making it easy to parse. Every word earns its place without being overly verbose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no annotations, no output schema, and a moderately complex operation (server-side HTTP send), the description is incomplete. It does not explain expected return values, error behavior, or the dependency on environment variables for optional overrides mentioned in the schema. An agent would lack clear expectations about what happens after invoking the tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema provides descriptions for all 5 parameters, giving 100% coverage. The description adds no additional parameter semantics, so the baseline score of 3 is appropriate. The schema already explains the purpose of each parameter, including optional overrides and defaults.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's function: transmitting a server-side analytics event to GA4 via the Measurement Protocol API. The verb 'transmits' and the resource (event to GA4) distinguish this from sibling tools that audit, generate, or validate data layer/tracking code.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies the use case (send an analytics event) but provides no explicit guidance on when to use this tool versus the siblings (audit, generate, validate). It does not mention when not to use it or name alternative tools, though the sibling names offer some contextual differentiation.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
validate_datalayer_eventB
Validates a GTM DataLayer event payload against GA4 & E-commerce schema standards to detect missing parameters or invalid types.
| Name | Required | Description | Default |
|---|---|---|---|
| eventPayload | Yes | The complete DataLayer event JSON object to validate |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It mentions the validation action and what it checks, but it does not disclose the return format, whether the tool is read-only, or any side effects. This leaves the agent without critical behavioral context for a validation tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is one concise sentence that front-loads the verb and object, with no filler words. It efficiently communicates the core purpose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With no output schema or annotations, the description needs to explain what the validation result looks like and how strict the standards are. It does not, leaving a significant gap for an agent to understand what the tool returns or how to interpret the outcome.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema documentation for the single parameter eventPayload and its nested properties is thorough (100% coverage). The description adds no extra parameter semantics beyond what the schema already provides, so the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool validates a GTM DataLayer event payload against GA4 and e-commerce schema standards, with the specific outcome of detecting missing parameters or invalid types. This specific verb+resource+outcome distinguishes it from sibling tools like send_ga4_measurement_protocol_event.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies a clear use caseβwhen you need to validate a DataLayer payloadβ but it does not explicitly mention when not to use it or compare with alternatives. The sibling tools are obviously different in function, but the guidance remains implicit rather than explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
4 tool updates
v1.0.0- First observed
audit_tracking_readiness - First observed
generate_tracking_code_snippet - First observed
send_ga4_measurement_protocol_event - First observed
validate_datalayer_event
TDQS
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
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Google Ads, Meta Ads & GA4 MCP server - 250+ tools for campaigns, creatives, audiences & reports.
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
- HasDataOAuthcom.hasdata
All HasData scraping tools in one MCP server: Google, TikTok, Instagram, maps, e-commerce and more.
- CalmSEOOAuthcom.calmseo
SEO MCP server for keyword research, SERP analysis, audits, and Search Console workflows.
Related MCP Servers
- AlicenseBqualityAmaintenanceProduction-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 audits1002,8541MIT
- AlicenseAqualityAmaintenanceMCP server for Google Tag Manager and GA4, enabling tag management, consent auditing, workspace versioning, and analytics reporting through natural language.18612MIT
- 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.91MIT
- AlicenseNot gradedqualityAmaintenanceAn open-source, local-first MCP server for automated Schema.org JSON-LD generation, GA4 metric validation, /llm.txt auditing, and content stickiness analytics.MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/webanalyticsprobd-maker/tracking-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server