Tracking protection and JavaScript errors

A few days ago I noticed redirect issues on one of our websites.  Instead of opening a new window with a download form (with window.open in JavaScript) the page took some of our FireFox visitors to our homepage.

I started debugging and immediately saw messages from FireFox about 3rd party scripts being blocked due to tracking protection settings.  Scripts like Google Analytics, Hotjar and others were blocked.  Visitors who had tracking protection enabled weren’t registering at all in analytics and other integrated tools.

Going back to the download links – they all triggered events in analytics registering the user action (a download in this case). Since Google Analytics was blocked the events were returning errors (what is ga??) and breaking the script execution. Guess what was the next line of code after the error?  Yes, opening the download window..

In order to avoid this there are 2 rules to follow:

  1. Always trigger events at the end of the script after executing all the crucial bits
  2. Don’t assume having all your external scripts loaded. Better verify before working with it:

    I wonder what will happen next – will tracking protection become the standard? If so, how will 3rd party scripts deal with it?

One comment

  1. You could also use:
    if (typeof ga === ‘function’) {
    ga(‘send’, ‘event’, ‘Download’, ‘Registration’, ‘Demo’);
    }

Leave a Reply

Your email address will not be published. Required fields are marked *