Troubleshooting: Malformed Tracking Snippets

How copying or sharing the Blue Tracely snippet can break it, such as curly quotes, lost quotes or a snippet nested in another tag, and how to fix each case.

The Blue Tracely snippet is one short <script> tag. It only works when it reaches your website exactly as the dashboard shows it. Most broken installations come from the way the snippet was copied or shared. This guide covers the common cases and how to fix them.

What a correct snippet looks like

Your snippet is on the Script page: select Install next to your domain, then Add it to your site's HTML, and look under Copy the script. It has this shape, with your own script address and key:

<script>
	!(function (key) {
		if (window.bluetracely) return;
		window.bluetracely = { loaded: true };
		var s = document.createElement("script");
		s.async = true;
		s.src = "https://<script address>/b/" + key + "/" + key + ".js.gz";
		var f = document.getElementsByTagName("script")[0];
		f.parentNode.insertBefore(s, f);
	})("ABCDEF123456");
</script>

When anything in it changes, browsers usually can't run it, the script never loads, and Test script reports "Error: We were unable to find the script on your website. Please ensure you have installed the script correctly." Your browser's console often shows a syntax error on that line.

1. Curly quotes

Chat apps, word processors and some email programs replace straight quotes (") with curly ones (“ and ”). Browsers don't read curly quotes as code, so the snippet stops working.

Example of broken code:

s.src=“https://<script address>/b/”+key+“/”+key+“.js.gz”;
  • Solution: Copy the snippet again with the Copy button on the Install page and replace the one on your site.
  • Tip: To send the snippet to a teammate, use Email it to a teammate on the Install the script page. In a chat app, paste it inside a code block, which keeps quotes as they are.

2. Missing quotes

Some chat and email programs turn the web address in the snippet into a clickable link. When the snippet is copied back, the quotes around the address can disappear, on one side or both.

Example of broken code:

s.src=https://<script address>/b/"+key+"/"+key+".js.gz";

Example of correct code:

s.src="https://<script address>/b/"+key+"/"+key+".js.gz";
  • Solution: Copy the snippet again from the Install page, or check that every quote around the address is in place before you paste it.

3. A snippet inside another <script> tag

If the snippet is pasted inside another script that's already on your page, the page ends up with one <script> tag inside another. That breaks the Blue Tracely snippet and can break the other script too.

  • Solution: Paste the snippet as a tag of its own, after the closing </script> of any other script, just before </head>.

4. A snippet inside a <style> tag

A <style> tag is for styles, not scripts. A snippet pasted there, often with its <script> tags removed, never runs.

  • Solution: Paste the full snippet, including its opening <script> and closing </script>, outside any <style> tag.

5. An edited or replaced snippet

  • The key was changed. The key at the end of the snippet tells the script which domain it belongs to. Don't edit it.

  • The snippet was replaced with a plain script tag. A tag such as <script src="https://<script address>/b/ABCDEF123456/ABCDEF123456.js.gz"></script> loads the file without the snippet. Test script then reports "Error: The website is running a different version of our script. Please validate that the script is installed properly and try again."

  • The snippet came from another domain. Each domain has its own snippet. Copy the one for the domain you're installing on.

  • Solution: Replace whatever is on the page with the snippet from the Install page for this domain.

Summary and best practices

  • Always copy the snippet with the Copy button on the Install page, and paste it unchanged.
  • Share it with Email it to a teammate, or inside a code block, never as plain chat text.
  • Paste it once, as its own tag, before the closing </head> tag, not inside another <script> or <style> tag.
  • After you fix it, select Test script on the Script page. To look at the page yourself, see Manually Verifying Your Script Installation.

If the snippet looks right and the script still doesn't run, write to us at hello@bluetracely.com.