Can JavaScript tell whether Tracking Protection is enabled in Firefox? -


so i've decided try google optimize conversion testing and, other tools, swaps stuff around via javascript.

to avoid flickery behaviour google recommends adding script sets opacity:0; entire page until either

  • a callback google analytics arrives signal page modifications have been completed
  • a timeout hit (4000ms default).

the callback relies on analytics.js executed.

with tracking protection enabled in firefox, google analytics blocked , callback never arrives. hence users of tracking protection feature greeted 4000ms of greyscreen on every pageload, waiting callback ga never come. far desirable.

now i'd remove greyscreen altogether users have analytics blocked. have not had luck in coming conditional can evaluate whether browser allows analytics loaded. there way tell in advance?

the solution not based on checking code analytics.js or on having timeout, since things i'm trying circumvent.

you can detect whether google analytics blocked or otherwise unavailable after fact, modifying tracking snippet add pages add error handler.

in snippet, after a.async=1;, add a.onerror=i.gafailedtoload; or similar. cause function window.gafailedtoload run moment google analytics blocked.

this not run on more advanced blockers such ublock origin, replaces analytics request neutered version.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -