Tag Manager: Create Trigger
gtm_create_triggerCreate one trigger in a draft workspace of a Google Tag Manager container: a page view, DOM ready, window loaded, click, link click, form submit, custom event or history change trigger, with conditions such as Page URL contains /thank-you, and for a custom event its event name. The trigger fires nothing until a tag uses it (gtm_create_tag, gtm_update_tag). 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>",
"name": "<name>",
"type": "<type>"
},
"name": "gtm_create_trigger"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The trigger's name, unique in the container, e.g. "Thank you page". | |
| type | Yes | Kind of trigger: PAGEVIEW, DOM_READY, WINDOW_LOADED, CLICK (any element), LINK_CLICK, FORM_SUBMIT, CUSTOM_EVENT (a dataLayer event) or HISTORY_CHANGE. | |
| notes | No | Notes shown on the trigger in Tag Manager. Optional. | |
| container | No | The 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. | |
| workspace | Yes | The 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. | |
| conditions | No | Conditions that must all hold for the trigger to fire; empty or omitted means every event of the type (every page view, every click). Each compares a variable with a value. At most 20. Built-in variables like Click Classes or Page Path must be enabled in the container to be used. | |
| event_name | No | CUSTOM_EVENT: the dataLayer event name that fires it, e.g. purchase or form_submitted. | |
| event_name_regex | No | CUSTOM_EVENT: treat event_name as a regular expression (e.g. ^(purchase|refund)$). Default false. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | Yes | PAGEVIEW, CLICK, CUSTOM_EVENT, … | |
| name | Yes | The trigger's name. | |
| type | Yes | Google's type code, e.g. pageview or customEvent. | |
| publicId | No | Public GTM-XXXXXXX id of the container. | |
| published | Yes | Always false: the change is a draft until a version is created and published. | |
| triggerId | Yes | Id of the new trigger inside the container. | |
| conditions | Yes | Its conditions as "{{Page URL}} contains /thanks" lines; the custom event name is one of them. | |
| workspaceId | Yes | Id of the workspace the change was saved in. | |
| workspaceUrl | Yes | Where the user reviews, previews and publishes the workspace in Tag Manager. | |
| containerName | Yes | The container's name. | |
| containerPath | Yes | API path of the container, accounts/{a}/containers/{c}. | |
| workspaceName | Yes | Name of that workspace. |