Skip to content

Instantly share code, notes, and snippets.

@hampusborgos
Last active June 3, 2018 09:54
Show Gist options
  • Save hampusborgos/08fa29d4317718c72d3e to your computer and use it in GitHub Desktop.
Save hampusborgos/08fa29d4317718c72d3e to your computer and use it in GitHub Desktop.
How to respect Do Not Track header and ignore IE
// Respect do not track for all browsers. Except for IE 10 and 11 where we ignore it
var dnt_isIe10or11 = (navigator.appVersion.indexOf("MSIE 10") !== -1) || (navigator.userAgent.indexOf("Trident") !== -1 && navigator. userAgent.indexOf("rv:11") !== -1);
var DNT = (navigator.doNotTrack || navigator.msDoNotTrack || window.doNotTrack);
DNT = !DNT || DNT == "unspecified" || DNT == "0" ? false : true;
if (!DNT || dnt_isIe10or11) {
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
// GA loading code
}
@sacredwx
Copy link

Why to cut off IE 10 and 11 ?

@tdelmas
Copy link

tdelmas commented Jun 3, 2018

@sacredwx :
https://hjnilsson.com/2015/11/30/setting-up-dnt/

Microsoft has made IE 10 & 11 set the value to true by default, in violation of the standard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment