Hello,
in order to anonymize Google Analytics I put the following in front of the Google Analytics tracking code
ga(‘create’, ‘UA-XXXXXXXX-X’, ‘auto’);
ga(‘set’, ‘anonymizeIp’, true);
ga(‘send’, ‘pageview’);
<script>
var gaProperty = ‘UA-XXXXXXX-X’;
var disableStr = ‘ga-disable-‘ + gaProperty;
if (document.cookie.indexOf(disableStr + ‘=true’) > -1) {
window[disableStr] = true;
}
function gaOptout() {
document.cookie = disableStr + ‘=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/’;
window[disableStr] = true;
}
</script>
Bits of this are now showing in the socket on the left hand side. Is there a chance to fix this?
Thanks for your assistance!
Hey hasbeat,
Please change your code to following one
<script>ga('create', 'UA-XXXXXXXX-X', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>
<script>
var gaProperty = 'UA-XXXXXXX-X';
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
window[disableStr] = true;
}
function gaOptout() {
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[disableStr] = true;
}
</script>
Best regards,
Yigit
Hi Yigit,
Thanks for your quick reply. The code is gone, however, the tracking code is still there.
Hi,
Code was wrong. I corrected it. Please see private content field below for more information
Best regards,
Yigit
Yigit – Great job, thank you so much!