How to Add a Cookie Consent Bar to WordPress

by Last Updated: Feb 4, 2023Blog, Divi theme

UPDATE: I no longer use the cookie consent banner plugin mentioned in this article. I have started using the Cookies and Content Security Policy plugin. Also, I have not tested yet if the process explained below in this tutorial still works.

This time I’m going to explain how you can add a cookie consent bar to your WordPress website or blog. If you use cookies on your WP website (e.g. you have Google Analytics installed or you have an affiliate program) and if you have visitors from the European Union, you are required to give a notice about using cookies to your visitors. It is an EU law requirement.

OK, now let’s mention what I will do. I will install 2 plugins for this: one will take care of displaying the cookie consent bar, and the other one will take care of that the cookie notice bar will show to European visitors only. It is required for the EU only, so why bother your US or Asian visitors with this, too.


Cookie Consent Notice Bar Preview


Also, I’d like to emphasize that this works with any WordPress theme, not just Divi, as these 2 plugins work independently of Divi. And both of these plugins are free.

So the first thing that you need to do is to install the GDPR Cookie Consent Banner plugin. Of course there are more cookie consent plugins, but I use particularly this one, because I like its design and I like the feature that it can be set to display for European visitors only (in combination with the second plugin that we will install next).

Now we will install the GeoIP Detection plugin. Then in the settings of this plugin choose the data source “Automatic download & update of Maxmind GeoIP Lite City”. And in the general options at the bottom don’t forget to tick the option “Add a country-specific CSS class to the <body>-Tag.”. This is important, because without this setting it didn’t work for me. So don’t forget to set this up.


GeoIP Detection Plugin Settings


Note: You will also need to register for a free account on the MaxMind website in order to be able to use the IP addresses databases. Then you will need to generate a license key and enter it in the plugin’s settings in your WP admin panel. It will also ask you a question saying that old versions of GeoIP Update program use a different license key format, so just choose “No”.

The last thing that we need to do is to setup the GDPR Cookie Consent Banner plugin. Go to Settings > Cookie Consent in your WP admin panel and you will be able to setup all the options for this plugin. In its general settings I choose all countries except Europe, in the “Exclude Zones” option. This shall make sure that the consent bar will show for European visitors only. Please note that you will need to have the GeoIP Detection plugin installed as well in order to be able to take the advantage of this feature.


GeoIP Plugin Exclude Zones


After that go to the “Content” settings and here you can write the texts for your consent bar as well as choose the “More Info Page” page. I would set this to your Privacy Policy page on which you should have explained that your website uses cookies. You can also choose the accept text for the button on the bar. I usually use just “OK” for this.


Cookie Consent Plugin Settings


And finally, in the Styles tab, you can customize the design of your cookie consent bar. You can choose the colors here and choose between top bar, bottom bar, top left block, top right block, bottom left block or bottom right block. This is up to you. As for me, I prefer just a typical bottom bar and I use the shades of gray as my colors.

So that’s it. I hope I have helped you with this article to make your website compliant with this EU law. And if you are looking for tips on how to add GDPR consent checkboxes to Divi theme or Bloom optins, check out my previous article on this blog.

5 Free WordPress Plugins You Should Use

Banner - Author Box for Divi Plugin


Author: Andrej

WordPress expert. Divi user since 2014. I blog about WordPress and Divi, my favorite WordPress theme. When I’m not working with WordPress or writing an article for this blog, I’m probably learning Italian. You can read more about me here.