How to Show Cookie Notice on WordPress Site Without any Plugins

A "cookie" is a piece of information that is stored on your computer's storage and which records how you move your way around a website so that, when you re-visit that website, it can present tailored options based on the information stored about your last visit.

What is Cookie?

A “cookie” is a piece of information that is stored on your computer’s storage and which records how you move your way around a website so that, when you re-visit that website, it can present tailored options based on the information stored about your last visit. Cookies can also be used to analyze traffic and for advertising and marketing purposes.

  • Cookies are used by nearly all websites and do not harm your system.

What is Cookie Law?

According to cookielaw.org
The Cookie Law is a piece of privacy legislation that requires websites to get consent from visitors to store or retrieve any information on a computer, smartphone or tablet.

It was designed to protect online privacy, by making consumers aware of how information about them is collected and used online, and give them a choice to allow it or not.

How to use a Cookie consent message in my site?

Well, in this tutorial I’ll show you how to set up a cookie notice on your WordPress website without installing any plugins. I will simply add a piece of code to use that.
Generally, in WordPress you can do this simple task by using any cookie consent plugins but as you may concern that for installing each and every additional plugin in your WordPress site it will increase the loading time of your website.[/vc_column_text][vc_column_text]Before starting you may need

    Access to your WordPress Admin Panel or website’s CPanel to edit a PHP file.

Step 1 — Generate the Cookie Notice Code

Visit cookieconsent.insites.com site.

Over there you can select your message displaying position (any one) the default position for this message is Banner bottom

How to Show Cookie Notice on WordPress Site Without any Plugins 1

You can also change your message box layout

How to Show Cookie Notice on WordPress Site Without any Plugins 2

You can also choose a different theme/palette for your message layout or you can create a new one

How to Show Cookie Notice on WordPress Site Without any Plugins 3How to Show Cookie Notice on WordPress Site Without any Plugins 4

In Learn More Link section you can anchor your custom cookie privacy page or you can leave it as default.

How to Show Cookie Notice on WordPress Site Without any Plugins 5

In this Compliance section, you can set cookie compliance type if you are not aware of this then leave it as default.

How to Show Cookie Notice on WordPress Site Without any Plugins 6How to Show Cookie Notice on WordPress Site Without any Plugins 7

In Custom Text section, you can set your own Custom Cookie Text Message if you are not aware of this then leave it as default.

How to Show Cookie Notice on WordPress Site Without any Plugins 8How to Show Cookie Notice on WordPress Site Without any Plugins 9

If all’s okay then finally, copy the right side generated code from there.
Well done, now we have to insert this piece of code to our site.

<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": "#000"
},
"button": {
"background": "#f1d600"
}
}
})});
</script>

Step 2 — Insert the Code in WordPress Site

Log in to your WordPress Admin panel and navigate to Appearance ➡️ Editor:
How to Show Cookie Notice on WordPress Site Without any Plugins 10How to Show Cookie Notice on WordPress Site Without any Plugins 11

Now, open the header.php file and paste the above-generated code in the header.php file, just before the tag.
Then click on Update File to save.

That’s all, you are successfully inserted cookie consent message in your website 🙂

How to Show Cookie Notice on WordPress Site Without any Plugins 12Conclusion:
Note: Before editing the header.php file, I would recommend you to keep a backup file so that if it’s going wrong for you can restore the file.
So, I hope in this article you have already learned how to display Cookie Notice on your WordPress site without any installing plugins. There is no need to install any plugin if the same functionality can be achieved by adding a piece of code into your existing header file.

Still getting trouble to make the code work!
Please feel free to comment here 🙂

Default image
MM Aurangajeb
Support Engineer, Blogger. Learning Web Design & Developing, Tech & WordPress Enthusiast, WordPress Lover. Always try to learn new things, new hacks, new techs.

Newsletter Updates

Enter your email address below to subscribe to our newsletter

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.