Codes


SCRIPT IM HEAD
---------------
<script>

/* Google Analytics Opt-Out*/

var gaProperty = 'UA-XXXXXX-Y';
var gaDisableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(gaDisableStr + '=true') > -1) {
window[gaDisableStr] = true;
}
function gaOptout() {
document.cookie = gaDisableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
window[gaDisableStr] = true;
}

</script>

SOURCE CODE MODUL FUSSZEILE
----------------------------

HTML
----
<a class="gaOptoutLink" onclick="gaOptout(); gaUpdateOptoutLinkText();" href="javascript:alert('Google Analytics Status: deaktiviert');">Google Analytics deaktivieren (hier klicken)</a>

JAVASCRIPT
----------
$(document).ready(function(){
if(window[gaDisableStr])
{
$('.gaOptoutLink').html('Google Analytics Status: deaktiviert');
}
});


Google Analytics Opt Out


Hello and welcome to this inCMS tutorial.

In this video I will explain you, how you can add an Google Analytics Opt Out, so that your visitors have the ability to deactivate Google Analytics.

You will find all codes, which I will show you in this video, in the description of this video. You can copy and paste them for your own use.

To add Google Analytics, edit the main folder here, then insert the Google Analytics Code in the head. 

Before the Google Analytics Script you can insert the Opt Out script. It is important, that you insert the ID of you Google Analytics account here.

Next go to the home page where you can insert a source code in a green global area, for example in the footer.

Now add the HTML code which is a link that says deactivate Google Analytics. And when a visitor clicks on it, Google Analytics will be deactivated and the text will be adapted and a notification will be shown, and for this, this Java-Script Code is needed.

Afterwards click and save and close and open your page in an incognito window, and as you can see, you now can deactivate Google Analytics here.

If you click on it, the text will be adapted. And if you go to another sub page, you will see the same text.

Our personal opinion is, that it’s not necessary to do all this, because even big websites don’t offer this option to their visitors. But if you’d like to give your visitors the ability to deactivate Google Analytics, here’s the solution to do it.