Skip to main content
Glama

Google Ads & Meta Ads

Tag Manager: Update Variable

gtm_update_variable
DestructiveIdempotent

Change one existing user-defined variable of a Google Tag Manager container in a draft workspace: a constant's value, a data layer variable's key or default, a URL variable's component or query key, a cookie's name, a JavaScript variable's name, a lookup table's input and rows, or any variable's name and notes. The variable's kind cannot change; only the arguments passed change. Saved in the existing workspace the user names (ask which) and NOT published: the user reviews and publishes in Tag Manager. Requires editing to be enabled on the Tag Manager connection.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "workspace": "<workspace>",
      "variable": "<variable>"
    },
    "name": "gtm_update_variable"
  }
}

Input Schema

NameRequiredDescriptionDefault
notesNoReplaces the notes on the variable. Optional.
valueNoCONSTANT: the constant's value.
new_nameNoA new name for the variable. Tags referencing the old {{name}} are not rewritten. Optional.
variableYesThe variable to change: its name or id, as gtm_list_triggers_variables shows them.
containerNoThe container: its public id (GTM-XXXXXXX), its name, or its API path from gtm_list_containers. May be left out when the connected login reaches exactly one container.
query_keyNoURL with url_component QUERY: the query parameter read, e.g. gclid.
workspaceYesThe existing Tag Manager workspace to save the draft in, by name or id, as the user named it (gtm_list_workspaces). Ask the user which workspace to use; never pick one yourself. Nothing is published.
cookie_nameNoCOOKIE: the first-party cookie read.
lookup_rowsNoLOOKUP_TABLE: rows as input value → output value, e.g. {"shop.example.com": "G-AAAA", "blog.example.com": "G-BBBB"}. Replaces the whole table on update.
lookup_inputNoLOOKUP_TABLE: the variable whose value is looked up, e.g. Page Hostname (with or without {{ }}).
decode_cookieNoCOOKIE: URI-decode the value. Default false.
default_valueNoDATA_LAYER or LOOKUP_TABLE: the value when the key is absent or no row matches. Optional.
url_componentNoURL: the part of the page URL: URL, PROTOCOL, HOST, PORT, PATH, QUERY, FRAGMENT.
data_layer_keyNoDATA_LAYER: the data layer key read, e.g. ecommerce.value or transactionId.
js_variable_nameNoJAVASCRIPT_VARIABLE: the global JavaScript variable read, e.g. window.dataLayerConfig.value (dot paths allowed).
data_layer_versionNoDATA_LAYER: 1 or 2 (default 2, the one with dot-path keys).

Output Schema

NameRequiredDescriptionDefault
nameYesThe variable's name after the change.
typeNoGoogle's type code, e.g. c or v.
changedYesThe arguments that were applied.
publicIdNoPublic GTM-XXXXXXX id of the container.
publishedYesAlways false: the change is a draft until a version is created and published.
parametersYesThe variable's parameters by key after the change, values as text.
variableIdYesId of the variable inside the container.
workspaceIdYesId of the workspace the change was saved in.
workspaceUrlYesWhere the user reviews, previews and publishes the workspace in Tag Manager.
containerNameYesThe container's name.
containerPathYesAPI path of the container, accounts/{a}/containers/{c}.
workspaceNameYesName of that workspace.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already flag this as a destructive, idempotent, open-world write, but the description adds genuinely useful behavior: the edit lands in a draft workspace and is NOT published, the variable kind is immutable, and the connection must permit editing. It does not describe failure modes (unknown variable, read-only workspace) or the response shape, so it is not fully complete.

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 verb and resource, then the per-kind field list, then the safety constraints — a sensible order. The middle clause is dense and long, but nearly every phrase carries actionable information (workspace selection, no publishing, permission requirement), so little is wasted.

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?

For a 16-parameter mutation tool with a documented output schema, the description covers scope, draft semantics, kind immutability, and the permission prerequisite. Missing are error behavior and whether to verify afterward with gtm_get_workspace_status, but the return values are covered by the output schema.

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 the baseline is 3; the description goes further by mapping argument families to variable kinds ('a data layer variable's key or default', 'a URL variable's component or query key') and by stating the cross-parameter constraint that only arguments change while the kind stays fixed. That cross-field rule is meaning the schema alone does not convey.

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 ('Change one existing user-defined variable of a Google Tag Manager container in a draft workspace') and then enumerates exactly which fields are editable per variable kind (constant value, data layer key/default, URL component/query key, cookie name, etc.). This clearly separates it from gtm_create_variable (new) and gtm_update_tag (different resource).

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?

Gives concrete operating context: work happens in the existing workspace the user names ('ask which'), nothing is published, and editing must be enabled on the connection. It does not explicitly name the alternative (gtm_create_variable) or state when-not to use it, which keeps it short of a 5.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources