Site logo

Archived topic

Cookie Consent Code

2 replies · Started by Zad on August 5, 2018

Viewing posts 1–3 of 3

Hi,

I'm trying to include some cookie consent code onto my site to comply with good GDPR practices. I stumbled on a site that provided me with this code (below). What I'm wondering is whether this belongs in GP Hooks in the wp_head section. This is where I've put it so far and it seems to be working fine. But I'm nervous as to whether or not I put it in the correct area. I already have some typekit code in there above this code so I'm nervous to add anything. Anyway, thanks!

<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
  "palette": {
    "popup": {
      "background": "#252e39"
    },
    "button": {
      "background": "#d46c5b"
    }
  },
  "theme": "classic",
  "position": "bottom-right",
  "content": {
    "message": "This website uses cookies to ensure you get the best experience on our website.",
    "href": "https://www.lesslikely.com/privacy-policy/"
  }
})});
</script>

I also want to be sure if this code is safe or if anyone here knows of any alternatives. Thanks!

Hi there,

the wp_head or the wp_footer is the right place for the code.
Adding it in the footer will mean the code loads after the page, so may reduce render blocking, so better initial page load times.

This archived topic is closed to new replies.