Atualizar tag no Google Tag Manager, por uma API
Substitui uma tag inteira: envie todos os campos a manter, como Get tag os retorna, com as mudanças, pois um campo omitido é apagado. Defina paused como true para parar uma tag sem excluí-la. A mudança só chega ao site depois de Create version e Publish version.
- Identificador
- google_tag_manager_update_tag
A chamada
POST https://connect.reportei.com/api/tools/google_tag_manager_update_tag/execute
Authorization: Bearer <merchant token>
x-customer-token: <customer token>
Content-Type: application/json
Accept: application/json
{
"customer_toolkit": "<connection UUID>",
"arguments": {
"accountId": "<accountId>",
"containerId": "<containerId>",
"workspaceId": "<workspaceId>",
"tagId": "<tagId>",
"name": "<name>",
"type": "<type>"
}
}Seu sistema envia o id da conexão do cliente e os argumentos da tool. Os headers são os mesmos de toda a API do Connect: o token do seu produto e o token do cliente.
Parâmetros
As descrições dos parâmetros seguem a documentação oficial do app, em inglês.
| Parâmetro | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| accountId | string | Sim | Account id from List accounts. |
| containerId | string | Sim | Container id from List containers: the number in containerId, not the GTM- code of publicId. |
| workspaceId | string | Sim | Workspace id from List workspaces. |
| tagId | string | Sim | Tag id from List tags. |
| fingerprint | string | Não | The fingerprint from Get tag: if the tag changed since then, Google refuses the update. |
| name | string | Sim | Name of the tag in Tag Manager. |
| type | string | Sim | Kind of tag, such as html for Custom HTML. For other kinds, copy type and parameter from a tag of the same kind with Get tag. |
| parameter | array | Não | Settings of the tag, which depend on its type. A Custom HTML tag takes a template parameter with key html and the code in value. |
| firingTriggerId | array | Não | Ids of the triggers that fire the tag, from List triggers or Create trigger. The tag fires when any of them is true. |
| blockingTriggerId | array | Não | Ids of the triggers that block the tag, from List triggers. While any of them is true, the tag does not fire. |
| paused | boolean | Não | true keeps the tag from firing without deleting it. |
| tagFiringOption | string | Não | How often the tag fires: unlimited, once per event or once per page load.Valores: unlimited, oncePerEvent, oncePerLoad |
| notes | string | Não | Notes about the tag. |
| liveOnly | boolean | Não | true fires the tag only in the live environment, not in preview. |
| priority | object | Não | Firing priority as an integer parameter: tags with a higher value fire first. The default is 0. |
| scheduleStartMs | string | Não | Start of the firing schedule, in milliseconds since 1970, as text. |
| scheduleEndMs | string | Não | End of the firing schedule, in milliseconds since 1970, as text. |
| parentFolderId | string | Não | Folder id of the tag, from Get tag. |
| consentSettings | object | Não | Consent the tag checks before firing. |
| monitoringMetadata | object | Não | A map parameter with key and value pairs added to the event data for tag monitoring. Its entries are template parameters without variables. |
| monitoringMetadataTagNameKey | string | Não | Key under which the tag name goes in monitoringMetadata. Empty leaves it out. |
| setupTag | array | Não | Tag that fires before this one. |
| teardownTag | array | Não | Tag that fires after this one. |
Conexões possíveis
O seu cliente conecta a conta do Google Tag Manager uma vez, por um dos modos abaixo. A mesma conexão serve para todas as tools do toolkit.
OAuth com o app do seu produto
Você cadastra o app OAuth do seu produto uma vez, em POST /api/merchants/credentials/google_tag_manager, e o cliente autoriza a conta numa tela de consentimento. O Connect renova o token quando ele está para vencer.
A resposta
Em caso de sucesso, o Connect preserva o status e o corpo da resposta do app. Erros HTTP retornados pelo app usam o envelope {error, api_error}; falhas de autenticação ou validação podem ocorrer antes da execução. O header X-Toolkit-Execution-Id identifica a execução registrada, consultável em GET /api/tools/executions/{uuid}.
Pronta para agentes de IA
O input desta tool é um JSON Schema, disponível em GET /api/tools/google_tag_manager_update_tag. Ele vira a definição de tool do seu agente sem conversão.
Outras tools do Google Tag Manager
- Listar contasGETLista as contas do Tag Manager que o usuário pode acessar, com accountId e name. Envie nextPageToken como pageToken para ler a próxima página.
- Listar contêineresGETLista os contêineres de uma conta, com containerId, name, publicId (o código GTM- instalado no site) e usageContext, como web. Envie nextPageToken como pageToken para ler a próxima página.
- Listar workspacesGETLista os workspaces de um contêiner, com workspaceId e name. Tags e acionadores são editados em um workspace, em geral o Default Workspace, e só chegam ao site por Create version e Publish version.
- Listar tagsGETLista as tags de um workspace, com tagId, name, type, parameter, firingTriggerId e paused. Envie nextPageToken como pageToken para ler a próxima página.
- Obter tagGETRetorna uma tag com todos os seus campos, incluindo fingerprint. Update tag substitui a tag inteira, então parta desta resposta.
- Criar tagPOSTCria uma tag em um workspace. Ela só chega ao site depois de Create version e Publish version. Sem firingTriggerId a tag nunca dispara.
- Excluir tagDELETEExclui uma tag de um workspace. O site continua disparando a tag até que uma versão sem ela seja publicada.
- Listar acionadoresGETLista os acionadores de um workspace, com triggerId, name, type e conditions. Um triggerId vai em firingTriggerId ou blockingTriggerId de uma tag. Envie nextPageToken como pageToken para ler a próxima página.
Toolkits da mesma categoria
Ver os 100 toolkitsVeja o Connect aplicado ao seu produto.
Teste por 15 dias sem cartão, ou mostre seu cenário ao nosso time.
