Usually when referring to Cookies, we’re talking about tracking scripts, such as Google Analytics, Tag Manager, Facebook Pixel etc.
The site itself uses internal Cookies for its functionality, so these are excluded from this topic.
You can enable the Cookie notice prompt in Customizer > General > Cookie Notice.
This prompt mainly serves as a simple method to notify the visitor that inside this website there are cookies used, and continuing visiting is basically an acceptance of this fact. So regardless of the customer’s input, the cookies will run, but will know about them.
If you do want to make the best use of this feature, i recommend containing your custom tracking scripts into a custom JS event (eg: reycore/cookie_notice/accepted
) that is fired when the user accepts, or, when the page is loaded and the prompt was already accepted eg:
add_action('wp_footer', function(){
?>
<script>
jQuery(document).on('reycore/cookie_notice/accepted', function(e, after_accepted_prompt ){
// scripts to execute
});
</script>
<?php
});
The after_accepted_prompt
argument will return true when the visitor clicks on the prompt Accept button.
Why there’s no “disagree” button?
As mentioned above, this is as a simple method to notify the visitor that the site uses cookies, and continuing visiting is basically an acceptance of this fact.
A disagree button would mean to stop those cookies from running in the site. This is pretty hard to do because the scripts and cookies should be gathered and added inside some container, which would wait for the customer’s input to be ran.
This is a complicated feature that would better be handled by a dedicated plugin such as https://wordpress.org/plugins/cookie-notice/ .