> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squid-id.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Tag Manager

> Add the Squid ID snippet through a Google Tag Manager Custom HTML tag that fires on Initialization - All Pages, then publish the container to start identifying visitors.

Google Tag Manager installs the snippet without touching your site's code. You create one Custom HTML tag, point it at every page, and publish the container. Copy your snippet from [Install the snippet](/getting-started/install-snippet) before you start, or use the one below with your own SDK key.

## The snippet

Replace `YOUR_SDK_KEY` with the key for your website, shown when you create a website and under **Settings → Website**.

```html theme={null}
<script>
  ;(function (squid) {
    window.$quid || (window.$quid = {})
    document.head.appendChild(
      (function (s) {
        s.src = 'https://app.asksquid.ai/tfs/' + squid + '/sdk'
        s.async = 1
        return s
      })(document.createElement('script')),
    )
  })('YOUR_SDK_KEY')
</script>
```

## Create the tag

<Steps>
  <Step title="Open Google Tag Manager">
    Go to [tagmanager.google.com](https://tagmanager.google.com/#/home) and sign in.
  </Step>

  <Step title="Open the right container">
    Find the account that owns the site you're installing on, then click the **container name** for that site. Containers are listed by name with their container ID (for example `GTM-XXXXXXX`) beside them. If you manage several sites, match the container name to the domain you want to identify visitors on, since publishing to the wrong container installs Squid ID on the wrong site.
  </Step>

  <Step title="Go to Tags">
    You land on the container workspace. Click **Tags** in the left sidebar.
  </Step>

  <Step title="Create a new tag">
    Click **New** at the top right of the Tags list. A panel slides open from the right.
  </Step>

  <Step title="Name the tag">
    Click the tag name at the top left of the panel and name it `Squid Tag`. Naming it now makes it easy to find later when you need to check or update it.
  </Step>

  <Step title="Choose Custom HTML">
    Click the **Tag Configuration** box, then under the **Custom** section choose **Custom HTML**.
  </Step>

  <Step title="Paste the snippet">
    Paste the full snippet, including the opening and closing `<script>` tags, into the **HTML** field. Leave **Support document.write** unchecked.
  </Step>

  <Step title="Set the trigger">
    Click the **Triggering** box, then choose **Initialization - All Pages**.
  </Step>

  <Step title="Save">
    Click **Save** at the top right. You are returned to the workspace and the new tag appears in the Tags list.
  </Step>
</Steps>

<Info>
  Choose **Initialization - All Pages** rather than **All Pages**. Initialization triggers fire before every other tag in the container, so Squid ID loads as early as possible in the page lifecycle and captures the full visit. On **All Pages** the snippet loads later and the first moments of a session can be missed.
</Info>

## Check it before publishing

Publishing pushes the tag to your live site, so it is worth confirming the tag fires first.

<Steps>
  <Step title="Enter Preview">
    Click **Preview** at the top right of the workspace and enter your site's URL. Tag Assistant opens your site in a new tab with a debug panel attached.
  </Step>

  <Step title="Confirm the tag fired">
    In the Tag Assistant panel, select the **Initialization** event in the left column. `Squid Tag` should appear under **Tags Fired**. If it sits under **Tags Not Fired**, the trigger is not matching, so reopen the tag and confirm the trigger is **Initialization - All Pages**.
  </Step>
</Steps>

## Publish

<Steps>
  <Step title="Select the tag">
    Back in the workspace, confirm `Squid Tag` is listed with type **Custom HTML** and trigger **Initialization - All Pages**.
  </Step>

  <Step title="Submit">
    Click **Submit** at the top right of the workspace.
  </Step>

  <Step title="Name the version">
    Optionally give the version a name and description, for example `Add Squid ID`. This is only for your own version history.
  </Step>

  <Step title="Publish">
    Click **Publish** at the top right. The tag is now live on your site.
  </Step>

  <Step title="Verify">
    Visit your site, then [verify the install](/getting-started/verify).
  </Step>
</Steps>

<Warning>
  GTM loads tags after the page, and some consent or performance plugins delay or block Custom HTML tags. If verification does not pass, check whether a consent tool is holding the tag back, then install the snippet directly in your site's `<head>` instead.
</Warning>

## Related

* [Install the snippet](/getting-started/install-snippet)
* [Verify your install](/getting-started/verify)
* [Plain HTML](/getting-started/install/plain-html)
