Installing the Unless snippet with Google Tag Manager (GTM)

Unfortunately, it is not possible to install the Unless script using Google Tag Manager (GTM). Find out why in the article.

If you have seen our installation guide, you probably remember that Unless's script needs to load in the < head > tag of your site, before any other elements load on the page and before your analytics scripts executes.

This is important to assure that Unless's personalizations are loaded correctly.

To make sure that Unless loads and integrates correctly, you must make sure that Unless starts loading before other tags on your page execute. There are two ways to ensure that this happens:

  • Load Unless in the < head > tag of your page, outside of a tag manager (recommended)
  • Use a tag manager that supports synchronous loading such as Tealium or Ensighten (but not Google Tag Manager which only supports asynchronous loading)

Why does Unless need to start loading first?

Because we apply visual changes to your website, Unless needs to start loading in the < head > tag, before other page elements load. This prevents the so-called flash of unstyled content and enables super fast personalization.

To make this happen, the script uses a mix of synchronous and asynchronous loading strategies. The Unless snippet fires synchronously - before anything else happens. It will tell request the required personalized content with a high priority and at great speed.

The personalized content will then download asynchronously - in parallel with your normal web page assets like stylesheets, scripts and images. Typically, the personalized content arrives way before your web page finishes loading all of its stuff. Then, Unless applies the personalized changes to your web page before it is visible and while it is still loading!

This way, your web page is as fast as it would be without personalization.

There is one exception

You can load our script in asynchronous mode if you only use add-ons and no on-site personalizations at all. Since add-ons are layered on top of your website, they are always loaded asynchronously and you won't have the flash of unstyled content problem.

To use our script in Google Tag Manager, you'll have to add another line of code to tell our script that it is loading asynchronously. Add the following line of code directly above your script code in GTM: