rubynz / kiwi-ruby-2017

The conference website for Kiwi Ruby 2017
https://2017-kiwi.ruby.nz
MIT License
2 stars 2 forks source link

Better handling of Google Analytics #43

Closed ndorfin closed 7 years ago

ndorfin commented 7 years ago

This PR:

See: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/doNotTrack

mermop commented 7 years ago

To be honest I haven't done DNT before - the MDN article you link to does note it's an experimental technology - are there any browser compatibility issues we might come across?

Should be fine though

ndorfin commented 7 years ago

With this polyfill:

function DNT () {
   if ('msDoNotTrack' in navigator) return navigator.msDoNotTrack;
   if ('doNotTrack' in window)      return window.doNotTrack;
   if ('doNotTrack' in navigator)   return navigator.doNotTrack;
   return 0;
 };

…we're saying: If your browser doesn't support DNT, then we'll set your DNT policy to 0 (or Track me by default). But if your browser does support DNT, through one of the 3 APIs we check for, then we'll check what your DNT status is. If DNT is 1, we don't load GA. If DNT is 0 (default) we'll load GA.

mermop commented 7 years ago

Right - should be fine then - let's put it up