How the snippet works

How does a tracking snippet work? This page walks through CROforce's, line by line. The snippet creates a small placeholder called entailInsights, loads entail.js in the background and hands over every call you made in the meantime. It never blocks your page.

On this pageThe snippetWhat each part doesThe placeholder (stub)When entail.js loadsInstalled twice? Nothing breaksBots and crawlersWhere to put it

Updated November 28, 2026

Not set
Find it on the install page of your account. It stays in this browser and is never sent anywhere.

You don't need to change anything in the snippet — copy it from the install screen as it is (see Install the tracking script). This page explains what each part does, so you can review it, load it from your own code, or debug it.

The snippet

HTML
<link rel="preload" href="https://cdn.entail-insights.com/js/entail.js" as="script">
<link rel="preconnect" href="https://widgets.entail.ai/" crossorigin>
<script>
  !function(t,e){var o,n,p,r;e.__SV||(window.entailInsights=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src="https://cdn.entail-insights.com/js/entail.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="entailInsights",u.toString=function(t){var e="entailInsights";return"entailInsights"!==a&&(e+="."+a),t||(e+=" (stub)"),e},o="trackEvent capture opt_out_capturing has_opted_out_capturing opt_in_capturing reset".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.entailInsights||[]);
  entailInsights.init('YOUR_SITE_TOKEN', { disable_decide: false });
</script>
Paste your site token at the top of the page to fill it in.

What each part does

Part

What it does

<link rel="preload">

Starts downloading entail.js as early as possible, before the script tag below asks for it.

<link rel="preconnect">

Opens the connection to widgets.entail.ai early, where your campaigns, popups and tests come from.

The inline script

Creates the entailInsights placeholder and adds an async script tag for entail.js.

entailInsights.init(…)

Tells the SDK which website it's on. The token identifies your website; disable_decide: false lets it read your website's settings. More options in
init options
.

The placeholder (stub)

Until entail.js arrives, window.entailInsights is a placeholder. Its methods don't do anything yet — they write each call into a queue. That's why you can call it from any script on the page without waiting:

JavaScript
// Works even if entail.js hasn't loaded yet: the call is queued.
entailInsights.trackEvent('start-trial', { plan: 'pro' });

The placeholder has these methods: init, trackEvent, capture, opt_out_capturing, opt_in_capturing and has_opted_out_capturing. Note that a queued has_opted_out_capturing() returns nothing useful — read it once the SDK has loaded.

When entail.js loads

  1. It replaces the placeholder with the real SDK, still at window.entailInsights.
  2. It runs your init call, then replays the queued calls in order. A queued opt-out is applied first, so nothing is stored or sent for a visitor who already declined (see Consent and privacy).
  3. It sends a page view and starts tracking clicks and form submissions (see Automatically tracked events).
  4. It reads your website's settings and shows the campaigns, popups, quizzes and A/B tests that apply to this page and visitor.

Methods that need the loaded SDK. get_distinct_id() and showPopup() aren't part of the placeholder. Call them after the SDK has loaded — for example from the loaded callback in init options.

Installed twice? Nothing breaks

The snippet sets a flag (__SV) the first time it runs, and the real SDK carries it too. A second copy — say one in your theme and another in Google Tag Manager — sees the flag and skips its setup, so the SDK loads once. A second init call is ignored, so the first copy's options are the ones that apply.

Bots and crawlers

When the visitor looks like a bot or a headless browser, the SDK only records the page view. It shows no campaigns, popups or tests to it. Search engines that index your pages still see your widgets' content, but are never put into an A/B test or redirected.

Where to put it

In the <head> of every page, ideally just before </head>. A/B tests change the page before visitors see it, so the earlier it runs, the less chance the original version flashes first. For redirect tests, see Redirect tests without flicker.

Frequently asked questions

Does the snippet block page rendering?

No. It adds

entail.js
as an
async
script, so the browser keeps drawing your page while the SDK downloads.

Can I call entailInsights before entail.js has loaded?

Yes, for

trackEvent
,
capture
,
opt_out_capturing
and
opt_in_capturing
. The placeholder queues those calls and the SDK runs them in order once it loads. Other methods exist only after the SDK has loaded — use the
loaded
option for those.

What if the snippet is installed twice?

The second copy sees the first and does nothing, so visits aren't counted twice. Only the first

init
call counts.

Was this article helpful?

Try it on your own site

Add a popup, form or quiz to your site in a few minutes and see what it does for your conversions.