How to add opt-out code

QUESTIONS & ANSWERSCategory: WordPressHow to add opt-out code
Profile photo of Nicole DornseifNicole Dornseif asked 2 years ago

 Hi,
love your plugin. But for Germany I need to add an opt-out code to the Google analytics code to set and check a cookie, for all users that doesn’t want to be analyzed by Google. In your tutorial video there was the option to add custom code. But this doesn’t exist anymore. 
I need to embed this opt-out code from Google:

<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>

Where do I need to put it? Thanks for your help.

Kind regards nik
3 Answers
Profile photo of DennisDennis answered 1 month ago

Can you please explain?
I have the same question.
Thank you.
Best regards
Dennis

Profile photo of DennisDennis answered 1 month ago

Hello,
Can anybody help how to inlcude the opt-out for germany. I have no idea how to do it with this plugin.
Thank you very much!
Best regards 
Dennis

Profile photo of Alin MarcuAlin Marcu Staff answered 4 weeks ago

Hi,
Here’s the procedure to disable tracking for analytics.js: https://developers.google.com/analytics/devguides/collection/analyticsjs/user-opt-out, and should be handled by your privacy/cookies consent plugin.

If your privacy/cookies consent plugin does that, there’s no need to set anything else in GADWP.