# Install with a tag manager

> Load the tag through Google Tag Manager with a Custom HTML tag, and what to watch for when a tag manager is in between.

This page shows how to load the Clear Saga tag through Google Tag Manager, for a site where the tag manager is the only place you can add code. If you can edit the `<head>` of your site directly, do that instead: it is simpler and has fewer things that can go wrong.

There is no ready-made template to import. You create one tag by hand and paste the code below into it. Replace `YOUR_SITE_KEY` with the key of your site, or copy the code from Settings, Installation, where the platform picker prints it with your key filled in.

## Google Tag Manager

1. Create a tag of type Custom HTML and paste this code.
2. Choose the All Pages trigger, save, and publish the container.

**Custom HTML tag**

```html
<script>
  (function () {
    var s = document.createElement('script')
    s.defer = true
    s.setAttribute('data-site-key', 'YOUR_SITE_KEY')
    s.src = 'https://clearsaga.com/js/script.js'
    document.head.appendChild(s)
  })()
</script>
```

> [!NOTE]
> If you use a consent tool, fire the tag only after consent for analytics. Blocking the tag also blocks the returning-visitors cookie. The code builds the tag in JavaScript to keep its data attributes.

## Why the code looks different

The other install guides show a plain tag. This one is a few lines of JavaScript that build the same tag and add it to the page. A tag manager inserts pasted code in its own way, and the attributes of a plain tag can get lost on the way. Building the tag in JavaScript keeps every one of them, the site key included.

## Things to watch for

- **One tag per page.** If the tag is also in your theme or template, remove it there. When the same key is on a page twice, only the first tag runs, so nothing is counted twice, and a leftover copy only causes confusion later.
- **Publish the container.** A tag that is saved but never published runs in the preview of the tag manager only.
- **Options are easier in the dashboard.** To switch on campaign capture or another option, use Settings, Installation, Tracking options. The script picks the change up by itself and the code in the tag manager stays as it is. The exception is Web Vitals, which needs the full script: after switching it on, copy the Google Tag Manager code from Settings, Installation again and replace the code in your tag. [Script options](/docs/script-options) explains each one.
- **Blockers.** A content blocker that removes the tag manager removes everything it loads, this tag included. Those visits are not counted.
- **Consent.** If a consent tool controls your tags, the tag only runs for visitors who agreed to analytics. Visitors who did not agree are not counted. A consent tool that blocks the tag also blocks the cookie of [returning visitors](/docs/returning-visitors). To remember visitors with a consent tool, choose "My own banner" under Settings, Visitors and call the function shown there from the tool's accept callback.

## Check that it works

Open your site in a normal browser window, outside the preview mode of the tag manager, then open the dashboard. The first visit shows up within a few seconds, and Settings, Installation changes to "Receiving data". If nothing arrives, [troubleshooting](/docs/troubleshooting) lists what to check.

**Next:** [Script options](/docs/script-options), [Troubleshooting](/docs/troubleshooting)
