Title: Opt Out Cookie
Last modified: June 18, 2018

---

# Opt Out Cookie

 *  Resolved [renatefink](https://wordpress.org/support/users/renatefink/)
 * (@renatefink)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/opt-out-cookie-3/)
 * Hi there!
    Due to a new law, I have to provide my customers with a link that 
   allows them to unsubscribe from GA tracking. That’s why I have to create an opt
   out cookie. Can you please help me with the creation? And where on my site do
   I have to enter the code? Thank you! Best Regards, Renate
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fopt-out-cookie-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [wbrubaker.a11n](https://wordpress.org/support/users/wbrubaker/)
 * (@wbrubaker)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/opt-out-cookie-3/#post-10415827)
 * Howdy 🙂
 * I had a look at the site and it appears that you are using this cookie notice
   plugin: [https://wordpress.org/plugins/cookie-notice/](https://wordpress.org/plugins/cookie-notice/)
 * In their documentation, they state:
 * > If you’d like to code a functionality depending on the cookie notice value 
   > use the function below:
 *     ```
       if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) {
           // Your third-party non functional code here
       }
       ```
   
 * The current version of the Google Analytics plugin provides a filter named `woocommerce_ga_disable_tracking`–
   if a callback function to that filter returns true then the WooCommerce Google
   Analytics code will not be loaded. So, with that in mind, a code snippet like
   this would do the trick: [https://gist.github.com/WillBrubaker/77bcc2c1ab8fd47c4b948f64a854021c](https://gist.github.com/WillBrubaker/77bcc2c1ab8fd47c4b948f64a854021c)
 * Hope that helps. Kind regards.
 *  [gore.m](https://wordpress.org/support/users/gorem/)
 * (@gorem)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/opt-out-cookie-3/#post-10435942)
 * Hi there,
 * may I know what should happen after `woocommerce_ga_disable_tracking` is used?
   
   Tracking code should not be presented or it should be changed? Im asking because
   Ive tried snipped recommended from github, but nothing happened, tracking code
   is everytime presented.
 * Isnt there easy solution like I did with Facebook for Woo Integration?:
 *     ```
       if ( function_exists('cn_cookies_accepted') && !cn_cookies_accepted() ) {
       	add_filter('facebook_for_woocommerce_integration_pixel_enabled', '__return_false', 20);
       }  
       ```
   
 * Thanks you
 *  [gore.m](https://wordpress.org/support/users/gorem/)
 * (@gorem)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/opt-out-cookie-3/#post-10435982)
 * Well, I found out that
 *     ```
       if ( function_exists('cn_cookies_accepted') && !cn_cookies_accepted() ) {
       	add_filter('woocommerce_ga_disable_tracking', '__return_true', 20);
       }
       ```
   
 * is working but there is an conflict with CometCache, that is not reflecting changes.
 *  [wbrubaker.a11n](https://wordpress.org/support/users/wbrubaker/)
 * (@wbrubaker)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/opt-out-cookie-3/#post-10445256)
 * Sounds like you’re all set here then.
    Have a fantastic day!

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

The topic ‘Opt Out Cookie’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-google-analytics-integration/assets/icon-256x256.
   png?rev=3234358)
 * [Google Analytics for WooCommerce](https://wordpress.org/plugins/woocommerce-google-analytics-integration/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-google-analytics-integration/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-google-analytics-integration/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-google-analytics-integration/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-google-analytics-integration/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-google-analytics-integration/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [wbrubaker.a11n](https://wordpress.org/support/users/wbrubaker/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/opt-out-cookie-3/#post-10445256)
 * Status: resolved