Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Google Analytics that respects Do-Not-Track header
var dnt = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
if (dnt != "1" && dnt != "yes") {
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
ga('create', 'UA-XXXXXXXX-X', 'auto');
ga('send', 'pageview');
} else {
console.debug("Respecting Do-Not-Track, not loading analytics. See");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment