Two tags, one or two triggers, and the settings that matter.
This is the recommended way to install Distil on sites that use Google Tag Manager (GTM).
Ready-made GTM setups are available on request. Distil can send you this setup as a file to import into GTM (Admin → Import Container → Merge): for your website on its own, or with OpenTable's widget, links to opentable.com, your own OpenTable booking form, or SevenRooms. After importing, you fill in two variables, your account key and your cookie banner's consent event, and publish. Ask Distil for the file for your setup. The steps below explain what it contains.
Before you start
- Delete any older Distil tags in the container, including old "first referrer" scripts. If two Distil tracking tags run on the same page, whichever loads first wins, and the other is ignored, so an old tag's settings can quietly take over.
- If your site has a cookie banner, find the name of
the event it sends to GTM when a visitor accepts: open GTM
Preview, accept the banner, and note the new event in
the left-hand list (ignore names starting
gtm.), or ask your banner provider. If no event appears, talk to Distil before going further. Then read Cookie consent.
Step 1: The starter script tag
In GTM, go to Tags → New and create:
| Setting | Value |
|---|---|
| Tag name | Distil - Starter Script |
| Tag type | Custom HTML |
| HTML | the starter script from the Quick start |
| Trigger | All Pages (GTM's built-in trigger) |
| Consent settings | No additional consent required |
Why All Pages: the starter script has to run as early as possible on every page, before your cookie banner is answered.
Step 2: The triggers for the tracking script
Go to Triggers → New and create:
| Setting | Value |
|---|---|
| Trigger type | DOM Ready |
| This trigger fires on | All DOM Ready Events |
Trigger B (only if your site has a
cookie banner): Distil - Consent given
| Setting | Value |
|---|---|
| Trigger type | Custom Event |
| Event name | your cookie banner's consent event |
| This trigger fires on | All Custom Events |
Why DOM Ready: it fires once the page's HTML has loaded, which gives the starter script time to run first, and gives the cookie banner time to restore a returning visitor's choice. In our tests, Initialization and All Pages fired too early: they missed returning visitors, and with some banners loaded Distil before consent (see Cookie consent → Loading for new and returning visitors).
Using OpenTable? If your site takes OpenTable bookings and your container is connected to OpenTable's Google Tag Manager integration, these triggers need one extra condition. The section for your booking setup explains what to add, and why:
Step 3: The tracking script tag
Create:
| Setting | Value |
|---|---|
| Tag name | Distil - Tracking Script |
| Tag type | Custom HTML |
| HTML | the tracking script from the Quick start |
| Triggers | Trigger A. If your site has a cookie banner, add Trigger B as a second trigger: either one fires the tag. |
| Consent settings (Advanced Settings → Consent Settings) | With a cookie banner: Require additional consent for tag to
fire → analytics_storage. Without one: No
additional consent required. |
| Tag firing options (Advanced Settings) | Once per event (the default) |
Never use "Once per page" or the "Consent Initialization" trigger for the tracking tag. "Once per page" loses the landing page of every new visitor who accepts. "Consent Initialization" can load Distil before the visitor has answered the banner, even if they then decline (see Cookie consent → Firing option).
The tag may fire twice on a page (on DOM Ready, and again when consent is given). That's expected and harmless: the second copy does nothing.
Step 4: Preview, then publish
- Click Preview in GTM and open your site.
- Run the checks in Testing your setup → Before publishing.
- Publish only when they all pass, then run the checks in Testing your setup → After publishing.
After publishing, check the live site again. If tracking stops, go to Versions, open the previous version, and ⋯ → Publish it to restore the old setup straight away.
Comments
0 comments
Article is closed for comments.