In this tutorial I am going to show you how to easily add a cookie notification popup to a WordPress website without installing any additional plugins.

Don’t get me wrong – I like plugins and I use a few of them on my websites. They are one of the main reasons that made WordPress so popular in the first place. With a simple click you can extend your website’s functionalities and give an easy answer to a complex technical problem. A few plugins might be a good thing for your website, however, they also come with a cost. The biggest problem with plugins is that they usually have many options that you are probably never going to use. Unnecessary code may increase the server load time and slow down your website, making it less appealing to your visitors. On top of that, sometimes plugin incompatibilities may appear that can even break your entire website. That is why, whenever possible, I always prefer the custom solution. Luckily, you do not need to install a plugin to add a cookie notification popup to your website. So, here is what I did to add cookie consent popup message to my WordPress website without installing any additional WordPress plugins.

Why Cookie Consent?

European Union’s GDPR law requires the website owners to notify the users about any cookies that their website is using. By default, WordPress uses cookies to collect login information that is necessary for users to log in. There are WordPress plugins that may also store visitor’s information. If you use analytics tools such as Google Analytics or you show ads via Google AdSense then you also use third-party cookies for storing information and you need to explicitly notify your website’s visitors about it. So, let’s get started adding cookie consent popup to our site.

How to Add Cookie Consent Popup in WordPress without a Plugin

In order to do this, we will use Cookie Consent by Insights. It is an open-source javascript code that will easily let you do just what you need and nothing more. In fact, you can use this code not only on WordPress but virtually on any other website. Navigate to their website and you will see the following screen:

On the left side are the options to configure the cookie consent notification bar. You have all the options you need to make it work just the way you want it. On the right side is the code that you need to copy after you finish with the configuration. You have the option to choose the popup position, the popup layout, the text, the link to your Privacy policy page and the button’s text. What I like the most is that you can actually see in real time on their website how the cookie popup will look like the moment you change any of the settings on the left corner of the screen. When you are done, copy the code and paste it in your child’s theme’s footer.php, just before the closing body tag.

Now, refresh the page and the cookie consent popup should now be visible. Happy coding!