5

I'm trying to accommodate GDPR by not loading our analytics scripts until the user consents.

The way I'm doing it works as expected in every browser we support but FF Quantum's private browsing window. (If it helps, it works as expected in Chrome Incognito)

This is the code that I'm using below:

/**
 * @name loadAnalytics
 * @function
 * @param {boolean} [consented] Determines if the consent click event should be tracked
 */
function loadAnalytics( consented ){
    if( analyticsExists() ) return callbackAnalytics( consented );
    if( !window.analyticsScriptURL ) return;
    var script = document.createElement( 'script' );
    script.src = analyticsScriptURL;
    script.type = 'text/javascript';
    script.async = true;
    script.onload = script.onreadystatechange = callbackAnalytics.bind( this, consented );
    document.head.appendChild( script );
}

Is this a security thing or is there something I'm missing?

Dave Maison
  • 383
  • 1
  • 13
  • could you check whether is there an error shown in dev console or not? – kucing_terbang May 22 '18 at 15:33
  • there aren't any errors. Its pretty bizarre. The script appears in the DOM, but the private window in firefox refuses to load it, in the normal window it loads fine. – Dave Maison May 24 '18 at 15:32
  • interesting. Is there any url I could try to visit to check it in my local workstation? Because I tried the same thing with the script from here and it seems work fine `https://www.w3schools.com/js/myScript.js` – kucing_terbang May 24 '18 at 16:34
  • unfortunately not, our dev servers aren't accessible outside our network, or rather, they're not supposed to be. – Dave Maison May 24 '18 at 20:24
  • @kucing_terbang it looks like your script works because it is not an analytics script. See the accepted answer below for more info. – Dave Maison May 29 '18 at 19:18

1 Answers1

3

After some research. It seems like the main reason you cannot load the script on the firefox private browser is because of tracking protection that is enabled by default.

You could try to disable it and see whether it happened again or not.

For further reference. Please see this https://support.mozilla.org/en-US/kb/tracking-protection?redirectlocale=en-US&redirectslug=tracking-protection-pbm

kucing_terbang
  • 4,991
  • 2
  • 22
  • 28
  • Bingo bango, that did the trick! Unfortunate that there's no user friendly solution for it, but good to know at least. – Dave Maison May 29 '18 at 19:07