The Impact of Script Placement on Profile Collection Efficiency

Why the Blue Tracely snippet belongs in the head of every page, and why placing it late or delaying it means fewer of your visitors are identified.

Where you paste the Blue Tracely snippet changes how many visitors it can identify. This article explains why the snippet belongs in the <head> of every page, and what happens when it loads late.

Where the snippet goes

The install instructions on the Script page ask you to add the snippet before the closing </head> tag on every page, or in your site's shared header template. Without it, a page reports no visitors.

Why placement matters

Blue Tracely doesn't report a page view the moment the page opens:

  1. The snippet loads the Blue Tracely script in the background.
  2. The script waits until the page has loaded, then about 3 seconds more, before it starts.
  3. It reports the page view about 6 seconds after it starts, or a little later if its identity checks are still running.

So the earliest a page view is reported is about 9 seconds after the page loads. A visitor who leaves, or moves on to another page, before then isn't reported from that page.

Anything that makes the script start later lengthens that wait:

  • The snippet at the end of the page. The browser reaches it later, so the script loads later. If the script arrives after the page has finished loading, its 3-second wait only starts then.
  • A tag or plugin that fires late. A tag manager rule or a website builder setting that adds the snippet some time after the page loads moves everything back by that much.
  • A plugin that delays scripts until the visitor interacts with the page. The script doesn't run at all for a visitor who reads and leaves without scrolling or clicking. See Why WP Rocket's "Delay JavaScript Execution" Can Break Blue Tracely Visitor Identification.

With the snippet in the <head>, the browser starts fetching the script as early as it can, so the script is usually ready by the time the page finishes loading.

The snippet loads the script asynchronously, so having it in the <head> doesn't hold up the rest of your page. See The Asynchronous Advantage of Blue Tracely's Script.

What can move the snippet out of the <head>

Check for these when you install:

  • A website template that only lets you add code to the page body or footer.
  • A page speed setting or plugin that moves scripts to the end of the page, or delays them.
  • A tag manager rule that fires the tag on a later event, or only on some pages.

If you can't edit your site's <head>

Use your platform's option for header code. The Script page explains two common ways:

Check your installation

After you move the snippet, go to the Script page and select Test script next to your domain. When the script answers from your site, you'll see "The script is installed on your website." See Verifying Your Script Installation.