Cookie Notice

You are here:
Estimated reading time: 1 min

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 jQuery (and Vanilla 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(){
      // here you can write the async analytics or tracking scripts, because the visitor has accepted the cookie notice.
    });
</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.

A disagree button would mean to stop those cookies from running in the site, however this is not an automatic process, but instead you need to grab all tracking/analytics scripts and place them inside the code snippet I mentioned above which only runs if the visitor accepted this.

This is a complicated feature that would better be handled by a dedicated plugin such as https://wordpress.org/plugins/cookie-notice/ .

Was this article helpful?
Dislike 1
Views: 1495

Suggest article improvements

Please use this form to suggest improvements and report missing or outdated content. Support requests will most likely not be answered and it's best to use the Support Request Form instead. Thanks!