Title: Opt-Out-Code?
Last modified: May 9, 2018

---

# Opt-Out-Code?

 *  [David181](https://wordpress.org/support/users/david181/)
 * (@david181)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/opt-out-code/)
 * Hi there,
 * any plans to insert a setting for the opt out code (before Google Analytics tracking
   code). It really helps for GDPR.
 * I inserted the code into the “before field” – but that is not working. Any tips
   or workarounds?
 * Thanks,
    David

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [nilsen](https://wordpress.org/support/users/nilsen/)
 * (@nilsen)
 * [8 years ago](https://wordpress.org/support/topic/opt-out-code/#post-10317820)
 * Hi,
 * i think you need to add this in the “after” field:
 *     ```
       // 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;
       }
       ```
   
 *  [nilsen](https://wordpress.org/support/users/nilsen/)
 * (@nilsen)
 * [8 years ago](https://wordpress.org/support/topic/opt-out-code/#post-10320259)
 * sorry this does not work. just use a plugin to do this, i used this one:
 * Google Analytics Opt-Out

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Opt-Out-Code?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/google-analyticator_fefefe.svg)
 * [Analyticator](https://wordpress.org/plugins/google-analyticator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-analyticator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-analyticator/)
 * [Active Topics](https://wordpress.org/support/plugin/google-analyticator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-analyticator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-analyticator/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [nilsen](https://wordpress.org/support/users/nilsen/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/opt-out-code/#post-10320259)
 * Status: not resolved