External scripts on your site could affect web analytics

I was recently asked to help troubleshoot someone’s web analytics instrumentation because the reports showed some weird data. Essentially, hardly any conversions were attributed to campaign sources and we just had a feeling that something was wrong.

Tagging looked good on every page, but when I looked at the resources being loaded it looked like the analytics pixel was firing twice! How could that be possible since the tag was definitely only once on the page?

Turns out that an innocuous looking external script was the culprit. External scripts look something like this:

<script type="text/javascript" src="www.domain.com/script.js" >

The script in question actually created an invisible iframe, which loaded the homepage thereby causing the pixel to fire twice. There may be a perfectly valid reason for a script to take this approach, but the effect on web analytics was obviously not considered.

If you have external scripts on your site, I would ask the vendors if there are any potential adverse effects on web analytics. In this case it was an iframe being created by a script, but also be wary of scripts making too much use of document.writes, especially if they are high up on the page. The browser will stop rendering the page  until whatever is called in the document.write is done. If this is slow it may affect your analytics tags as well, let alone create a bad user experience. Better use the DOM/async.