Created
October 31, 2017 15:34
-
-
Save anonymous/93bdbf6aa394c7176da92d71b44d17e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="javascript:gaOptout()">Click here to opt-out of Google Analytics</a> | |
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment