# Google Tag Manager

> Load the Taggor snippet through a Google Tag Manager Custom HTML tag.

> Esta página ainda não tem tradução para o português; este é o texto em inglês. (This page is not translated yet: the English text follows.)

Use this when the site already runs Tag Manager and nobody can edit its templates. Tag Manager loads the
script; the component's tag still has to be on the page, so this guide covers the loader only.

## Install the snippet once

1. In your container, create a **Custom HTML** tag.
2. Paste the snippet:

```html title="index.html"
<script async src="https://cdn.taggorcdn.com/s/<site-key>.js"></script>
```

3. Trigger it on **All Pages** (or on the pages that hold components), preview in Tag Manager's preview mode,
   then publish the container.

Tag Manager asks that JavaScript sit inside script tags and turns `document.write` off by default
(Custom HTML tag, `https://support.google.com/tagmanager/answer/6107167`, read 2026-11-10). The snippet needs neither
`document.write` nor anything else switched on. The page says nothing about loading an external script or about
when the tag fires; the second part we tested, below.

## Place the component

Write the tag in the page's own HTML, as in [Install the snippet](https://taggor.dev/docs/snippet.md); Tag Manager does not
place it for you.

## Limits

- Tag Manager adds the script when its trigger fires, so the component appears later than with a snippet in
  the page. The tag must have a fallback inside it ([Fallback content](https://taggor.dev/docs/fallback.md)).
- A consent tool that blocks Tag Manager until the visitor accepts also blocks the component. The component
  then stays as the page wrote it.
- Tag Manager minifies Custom HTML and may turn single quotes into double quotes. Harmless for the snippet.

## Common problems

- **The component appears a moment after the page.** Expected with a late trigger: reserve its size with
  `:not(:defined)` so the page does not jump.
- **Nothing happens in preview.** The trigger did not fire on that page, or an ad blocker blocks Tag Manager;
  the page stays intact either way.

## How we checked

The fixture `platform-gtm` adds the script element after the page's `load` event, the way Tag Manager adds
a script, and the tags already on the page mount when it arrives, in Chromium, Firefox, WebKit and two mobile
emulations. Not checked: no Tag Manager container was used.
