How to Add a Cookie Consent to WordPress

  • By Darrel Wilson
  • Last Updated: November 21, 2019

It seems like no matter where you go online, more and more websites are displaying cookie notices. Thanks to last year’s uproar about the new European regulation known as GDPR and EU cookie policy which is a result of an increasing number of security breaches, it’s no wonder that cookie notices are becoming commonplace.

If you still haven’t added a cookie notice to your website, all is not lost. In this tutorial, I’ll explain what cookies are, how WordPress uses cookies, and how to add a cookie consent to your WordPress website.

What Are Cookies

According to Mozilla’s Developer Network’s definition, an HTTP Cookie is a is a small piece of data that a server sends to the user's web browser. The browser may store that data on the user’s computer and send it back the next time this user visits the same website.

Cookies are mainly used for the following purposes:

  • To preserve session data such as logins, shopping carts, game scores, and more
  • To save user preferences and other settings
  • And to track and analyze user behavior.

How WordPress Uses Cookies

WordPress uses cookies in several ways. First, it stores your session information as well as session information for any logged in user. Various plugins such as WooCommerce, for example, use cookies to store the number of items a user has added to the cart or the contact information such as a person’s website and email for commenting purposes.

Since cookies are not only used to store information but can also be used to track information and share it with third-party websites, you are required to notify your users about your website’s use of cookies, more specifically, how and why you collect, store, and use them. This is especially true if you’re serving visitors from the EU and a few other countries that have strict cookie laws.

How to Add A Cookie Consent Notice With a Plugin

Now that we’ve covered what cookies are, how they work, and how WordPress uses cookies, let’s go over what a cookie consent is and how to add a cookie consent notice to your WordPress website with a plugin.

A cookie consent is a simple notice that appears when a visitor lands on your website. It can be as simple as simply informing a user that your website uses cookies or it can also allow visitors to accept or reject cookies.

When it comes to displaying cookie consent in WordPress, there is no shortage of plugins. Below, I’ll briefly go over the top four cookie consent plugins for WordPress and then show you how to use one of them on your WordPress website.

1. GDPR Cookie Consent Banner

The first plugin on the list, GDPR Cookie Consent Banner boasts over 200,000 live installs and a 5-star rating. The plugin is quite simple to use and you can even use their website to generate a privacy policy for free if you don’t already have one. This plugin’s options allow you to customize how the cookie consent looks like, where it appears, as well as the text that displays. You can also exclude certain countries from seeing your cookie policy.

2. EU Cookie Law

The EU Cookie Law plugin is another popular plugin with more than 100,000 active installs and 4,5-star rating. This plugin has slightly more options than the previous plugin and gives you the option to inform users that your site has cookies, with a popup for more information, and option to lock scripts before acceptance. The benefit of this plugin is that you can easily insert the cookie consent onto any page or post through the shortcode.

3. GDPR Cookie Consent

The GDPR Cookie Consent plugin is a robust plugin that offers a plethora of options when it comes to displaying cookie consent notices. Not only can you customize the text and where the notice will appear but you can also customize how the cookie consent looks like, as well as set styles for the accept and reject buttons, and more. The GDPR Cookie Consent plugin also comes with the ability to create a list of cookies and store information about non-necessary cookies.

4. WF Cookie Consent

The last plugin on the list, WF Cookie Consent, shows the user a clear message that the site uses cookies. It also supports multi-language installations and is the simplest plugin on this list in terms of settings and customization. If you’re looking for a straightforward plugin with minimal configuration, WF Cookie Consent is the right choice.

How to Add Cookie Consent Notice to WordPress With GDPR Cookie Consent

For the purposes of this tutorial, we’ll be using the GDPR Cookie Consent plugin as it offers the most options out of the four.

Here’s how to use the plugin:

  1. In your WordPress dashboard, go to Plugins > Add new. Search for GDPR Cookie Consent, install and activate the plugin.
  1. Go to GDPR Cookie Consent and click on Cookie Law Settings. On the General tab, configure how you want your cookie consent to show up on your website. You can choose between banner, popup or a widget and decide whether the notice should be animated and auto-dismissed.
  1. Customize the styles by tweaking the settings under the Customize Cookie Bar and Customize Buttons.
  1. Link to your privacy policy page by going to Customize Buttons > Read More Link.
  1. When you’re done tweaking the settings, click the Update Settings button and visit your website to see how your cookie notice looks.

How to Add a Cookie Consent Notice Without a Plugin

As with anything WordPress related, there is a way to add a cookie consent notice to your WordPress website without using a plugin. This step will require copying and pasting a code snippet into your header.php file. Here’s how to do it.

1. Visit Cookie Consent by Insites

Start by navigating to Cookie Consent’s website. This is a free and open-source solution for displaying cookie consent on your website that can be customized not only in terms of how it looks on your site but also in terms of consent type.

2. Customize Your Cookie Consent

Click on the download button. You will be taken to a new page where you can choose where the cookie consent should appear, how it looks, and which consent type you want to use. You can choose from a simple cookie notification or from a more advanced notification that allows visitors to accept or disable the cookies. For the purposes of this tutorial, I’ve chosen a simple cookie notification but you can choose your preferred consent type.

3. Add the Cookie Consent Code to Your WordPress Website

When you’re done generating and customizing your cookie consent, copy the provided code. Go back to your WordPress dashboard and navigate to Appearance > Editor and open up your header.php file. Paste the generated code there, save the changes, and close the editor.

Alternatively, you can use a plugin like Head and Footer Scripts Inserter to insert the script into your website without having to touch the theme files.

4. Check Out Your Cookie Consent

All that’s left to do now is to visit your website and make sure the cookie consent notice displays properly.

Final Thoughts

Adding a cookie consent notice helps you stay compliant with the laws and informs your users on which data you’re collecting and how you use it. Use this tutorial to add cookie consent to your WordPress website with or without the help of plugins.

Like This Article?

I have tons of great free content and giveaways! Join 10,000+ others and get access to coupons, freebies, and other great wordpress tips and tricksfor your wordpress website!

Leave a Reply

Hi, Sign Up For Freebies And Wordpress News!

Hi, Sign Up For Freebies And Wordpress News!

Join My Mailing List For Tips, News, And Discounts!

You have Successfully Subscribed!

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!