Skip to main content
Glama
kLOsk

AdLoop: Google Ads, Reddit Ads & GA4

Draft a Tag Manager variable

draft_gtm_variable

Create or update a Google Tag Manager variable in a workspace and return a preview; changes stay unpublished until you publish.

Instructions

Draft creating or updating a Tag Manager variable: returns a PREVIEW.

Without variable_id this creates a variable in a workspace; with variable_id it updates the existing one. Data Layer Variables, the usual source for GA4 ecommerce values, take data_layer_key (e.g. "ecommerce.value") instead of raw parameters. Tags and triggers use a variable as {{name}}; renaming one they reference is refused, because the references would break (the GTM UI renames safely). Custom JavaScript variables run code on the site and are refused unless gtm.allow_custom_html is set. The edit lands in the workspace and changes nothing on the site until the workspace is published. Refused unless gtm.write_enabled is set.

Tag Manager API: https://developers.google.com/tag-platform/tag-manager/api/v2

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoVariable name, 1-200 characters without curly braces. Required when creating a variable.
notesNoFree-form note stored on the variable. None keeps the current note.
parametersNoGTM parameter dicts with at least "type" and "key" for the other types, e.g. a Constant's [{"type": "TEMPLATE", "key": "value", "value": "G-ABC123"}]. On update they merge by key.
variable_idNoExisting variable ID to update (see list_gtm_variables). Empty creates a new variable.
workspace_idNoWorkspace to edit (see list_gtm_workspaces). Empty uses the Default Workspace, or the only workspace there is.
default_valueNoFor Data Layer Variables: the value when the key is missing. None sets no default.
variable_typeNoRequired when creating, fixed afterwards: v (Data Layer Variable), c (Constant), u (URL), k (1st-party cookie), j (JavaScript Variable, reads a global), aev (Auto-Event Variable), d (DOM element), f (HTTP referrer), e (Custom event), smm (Lookup table), remm (RegEx table), jsm (Custom JavaScript, gated) or cvt_<id> for a custom template.
data_layer_keyNoFor Data Layer Variables: the dataLayer key to read, dot notation for nested values, e.g. "ecommerce.transaction_id".
gtm_account_idNoNumeric GTM account ID (see list_gtm_accounts). Empty uses gtm.account_id from the config.
gtm_container_idNoNumeric GTM container ID (see list_gtm_containers). Empty uses gtm.container_id from the config.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.32.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations only give readOnly=false, destructive=false, openWorld=true, so the description carries real weight. It discloses that edits stay in the workspace until published, that referenced-variable renames are refused, that Custom JavaScript is gated, and that update parameters merge by key — all behavioral traits beyond the annotations.

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?

The critical statement (draft + returns a PREVIEW) is front-loaded and each subsequent sentence covers a distinct concern (create/update, data layer, references, gating, publish semantics, write gate). Slightly dense but no padding.

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

Completeness5/5

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

An output schema exists so return values needn't be described, and the description covers the create/update decision, refusal conditions, and workspace-vs-published semantics. For a 10-param, gated mutation tool this is essentially complete.

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

Parameters4/5

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

Schema coverage is 100%, so baseline is 3, but the description adds genuine meaning: it explains that Data Layer Variables take data_layer_key instead of raw parameters, names the {{name}} reference convention, and clarifies workspace_id / variable_id fallback behavior that the schema alone doesn't tie together.

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

Purpose5/5

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

States a specific verb and resource ('Draft creating or updating a Tag Manager variable') and immediately flags the PREVIEW return, which distinguishes it from get_gtm_variable and list_gtm_variables siblings. It also disambiguates create vs update via variable_id in the same breath.

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

Usage Guidelines4/5

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

Clearly explains the two modes (without variable_id = create in a workspace; with variable_id = update) and names the prerequisite gates (gtm.write_enabled, gtm.allow_custom_html). It doesn't explicitly route to sibling alternatives like draft_gtm_tag or draft_gtm_trigger, but the create/update conditions are unambiguous.

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