dominikmatt / trackingJS

A simple google Analytics Tracking Plugin
Apache License 2.0
4 stars 6 forks source link

opt-out #51

Open dominikmatt opened 8 years ago

dominikmatt commented 8 years ago
<script> 
// Set to the same value as the web property used on the site
var gaProperty = 'UA-XXXX-Y';

// Disable tracking if the opt-out cookie exists.
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
  window[disableStr] = true;
}

// Opt-out function
function gaOptout() {
  document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
  window[disableStr] = true;
}
</script>
natterstefan commented 8 years ago

:+1: