Draft a Tag Manager variable
draft_gtm_variableCreate 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
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Variable name, 1-200 characters without curly braces. Required when creating a variable. | |
| notes | No | Free-form note stored on the variable. None keeps the current note. | |
| parameters | No | GTM 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_id | No | Existing variable ID to update (see list_gtm_variables). Empty creates a new variable. | |
| workspace_id | No | Workspace to edit (see list_gtm_workspaces). Empty uses the Default Workspace, or the only workspace there is. | |
| default_value | No | For Data Layer Variables: the value when the key is missing. None sets no default. | |
| variable_type | No | Required 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_key | No | For Data Layer Variables: the dataLayer key to read, dot notation for nested values, e.g. "ecommerce.transaction_id". | |
| gtm_account_id | No | Numeric GTM account ID (see list_gtm_accounts). Empty uses gtm.account_id from the config. | |
| gtm_container_id | No | Numeric GTM container ID (see list_gtm_containers). Empty uses gtm.container_id from the config. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||