Last active
July 4, 2018 16:57
-
-
Save coxmi/c7c89e19e93edf523f6b7a1478af0d05 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
// can use a random UUID for clientID | |
// from: https://gist.github.com/jed/982883 | |
function uuid(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,uuid)} | |
// stops analytics from working at all | |
window['ga-disable-UA-XXXXX-Y'] = true; | |
// using ga.js | |
// anonymise IP address | |
ga('set', 'anonymizeIp', true); | |
// disable AdWords, DFP, retargeting, etc | |
ga('set', 'allowAdFeatures', false); | |
// ga clientID is still a unique identifier | |
// so we either need to pass a fake clientID into the ga init call | |
ga('create', 'UA-XXXXX-Y', { 'clientId': clientId }); | |
// or stop using any cookies at all | |
ga('create', 'UA-XXXXX-Y', { storage: 'none' }); | |
// remove _gac_property-<id> (used in AdWords conversion tracking) | |
ga('create', 'UA-XXXXX-Y', { storeGac: false }); | |
// set cookie expiration to zero turns _ga into a session cookie | |
ga('create', 'UA-XXXXX-Y', { cookieExpires : 0 }) | |
// using gtag.js | |
// anonymise IP address | |
gtag('config', 'UA-XXXXX-Y', { anonymize_ip: true }); | |
// disable AdWords, DFP, retargeting, etc | |
gtag('config', 'UA-XXXXX-Y', { allow_display_features: false }); | |
// ga clientID is still a unique identifier | |
// so we need to pass a fake clientID into the ga init call | |
gtag('config', 'UA-XXXXX-Y', { user_id: clientId }); | |
// or stop using any cookies at all | |
gtag('config', 'UA-XXXXX-Y', { storage: 'none' }); | |
// remove _gac_property-<id> (used in AdWords conversion tracking) | |
gtag('config', 'UA-XXXXX-Y', { store_gac: false }); | |
// set cookie expiration to zero turns _ga into a session cookie | |
gtag('config', 'UA-XXXXX-Y', { cookie_expires: 0 }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment