Skip to main content
Glama
kLOsk

AdLoop: Google Ads, Reddit Ads & GA4

Generate tracking code

generate_tracking_code
Read-only

Create a ready-to-paste GA4 event tracking JavaScript snippet. Add recommended parameters and check if the event already fires.

Instructions

Generate a GA4 event tracking JavaScript snippet.

Produces ready-to-paste gtag code for the specified event. Includes recommended parameters for well-known GA4 events (sign_up, purchase, etc.). Optionally checks GA4 to warn if the event already fires. Returns the javascript snippet, already_exists / existing_count from GA4, and notes (duplicates, marking it as a key event, GDPR consent).

Google Analytics Data API: https://developers.google.com/analytics/devguides/reporting/data/v1 and Google Ads API: https://developers.google.com/google-ads/api/docs/start

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
triggerNo"form_submit", "button_click", or "page_load" — wraps the gtag call in an appropriate event listener (with a YOUR_SELECTOR placeholder for forms and buttons). Empty = bare gtag call.
event_nameYesGA4 event name for the snippet, e.g. "sign_up" or "generate_lead".
property_idNoGA4 property as "properties/123456789" used for the existing-event check. If empty, uses the default from config.
event_paramsNoEvent parameters as a name-to-value object, e.g. {"method": "email"}. Missing recommended parameters for well-known events are added as typed placeholders.
check_existingNoWhen true (default), looks up the last 28 days of GA4 events to report whether this event already fires.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv0.27.1
    • addedInput schema / properties / check_existing / description
      Added value: +"When true (default), looks up the last 28 days of GA4\nevents to report whether this event already fires."
    • addedInput schema / properties / event_name / description
      Added value: +"GA4 event name for the snippet, e.g. \"sign_up\" or\n\"generate_lead\"."
    • addedInput schema / properties / event_params / description
      Added value: +"Event parameters as a name-to-value object, e.g.\n{\"method\": \"email\"}. Missing recommended parameters for well-known\nevents are added as typed placeholders."
    • addedInput schema / properties / property_id / description
      Added value: +"GA4 property as \"properties/123456789\" used for the\nexisting-event check. If empty, uses the default from config."
    • addedInput schema / properties / trigger / description
      Added value: +"\"form_submit\", \"button_click\", or \"page_load\" — wraps the gtag\ncall in an appropriate event listener (with a YOUR_SELECTOR\nplaceholder for forms and buttons). Empty = bare gtag call."
  2. Addedv0.13.2
  3. Removedv0.13.0
  4. First observedv0.9.0

TDQS

A3.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and destructiveHint=false, so safety is covered. The description adds genuine behavioral context beyond them: the GA4 lookup window behavior, the automatic placeholder insertion for well-known events, and the consent/key-event/GDPR notes returned alongside the snippet.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core purpose in the first sentence, then a compact paragraph on behavior and outputs. The trailing Google Analytics Data API / Google Ads API documentation links are irrelevant to invoking this tool and are the only wasted text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists and annotations cover the safety profile, so the description needn't explain return values — yet it usefully summarizes them (snippet, already_exists, existing_count, notes). What remains missing is guidance on when to prefer this over the sibling tracking-validation tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all five parameters are already documented in the schema, making 3 the baseline. The description restates the existing-event check and the recommended-parameter behavior but adds no syntax or format detail beyond what the schema properties already say.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: 'Generate a GA4 event tracking JavaScript snippet' with ready-to-paste gtag code. The output and scope are clear, but it never distinguishes itself from nearby siblings such as validate_tracking, get_tracking_events, or audit_event_coverage, so an agent must infer the boundary.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied by the phrases 'for the specified event' and 'Optionally checks GA4 to warn if the event already fires', which maps to the check_existing parameter. There is no explicit when-not guidance and no named alternative tool, so routing between this and validate_tracking/audit_event_coverage is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools