Implementing Java script on my site

Alexander_Giann
Tourist
8 1 4

Hey everyone, 

due to a new law in germany, I have to implement a java script on my site and give the visitors the opportunity to deny getting tracked by google analytics.

https://webgilde.com/en/analytics-opt-out/

The code is: (ignore the german instructions in it)

<script>
// Verwenden Sie Ihre Tracking-ID, wie oben beschrieben.
var gaProperty = 'UA-XXXXXXXX-YY';

// Deaktiviere das Tracking, wenn das Opt-out cookie vorhanden ist.
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
  window[disableStr] = true;
}

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

the link to deny the tracking is:

<a href="javascript:gaOptout()">diesen Link</a>

amd has to be implemented in my privacy policy. Does anyone has an idea how to do it ? 

Thanks in advance!!

 

If I could help you, then please Like and Accept Solution.
0 Likes