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/
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
Hope that helps. Kind regards.
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
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.
Sounds like you’re all set here then.
Have a fantastic day!