GTM: Create or change tag/trigger/variable
gtm_save_entityCreates a new GTM entity or fully replaces an existing tag, trigger, or variable in a workspace. Include the fingerprint on updates to prevent overwriting concurrent changes.
Instructions
Without entityId: creates the entity (POST). With entityId: replaces it completely (PUT) — fetch it first via gtm_list_entities, change it and send it back in full; if entity.fingerprint is included, GTM aborts if it was changed in the meantime. Example GA4 event tag: {"name":"GA4 – generate_lead","type":"gaawe","parameter":[{"type":"template","key":"eventName","value":"generate_lead"},{"type":"template","key":"measurementIdOverride","value":"G-XXXX"}],"firingTriggerId":["12"]}. Pre-check: JavaScript in Custom HTML tags and Custom JS variables must be ES5 strict (no let/const/arrow, no function declaration in try/if/for), every {{Variable}} must exist in the workspace.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity | Yes | GTM resource in API format (tag, trigger, variable …) | |
| entityId | No | ID of the existing entity (tagId/triggerId/variableId …) → update | |
| accountId | Yes | GTM accountId (from gtm_list_accounts) | |
| entityType | Yes | Entity type: tags, triggers, variables, folders, templates, clients, transformations, zones | |
| containerId | Yes | GTM containerId, numeric | |
| workspaceId | Yes | Workspace ID (from gtm_list_workspaces / gtm_create_workspace) | |
| skipValidation | No | Skip the pre-check — only for a proven false positive |