Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoogleAnalytics OptOut JS [DSGVO|GDPR] #332

Open
riconeitzel opened this issue Jun 16, 2018 · 0 comments
Open

GoogleAnalytics OptOut JS [DSGVO|GDPR] #332

riconeitzel opened this issue Jun 16, 2018 · 0 comments

Comments

@riconeitzel
Copy link
Member

The Privacy Policy section about Google Analytics requires an optout link. this link creates an opt-out cookie that is respected by the tracking code.

OptOut Link:
<a onclick="alert('Google Analytics wurde deaktiviert');" href="javascript:gaOptout()">Google Analytics deaktivieren</a>

the following code needs to be present in the <head> of every page.

<script type="text/javascript">// <![CDATA[
// 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant