Back to the blog
Guide

Cookie consent on WordPress: a setup guide for non-developers

You run a WordPress site and need to sort out cookie consent. You are not a developer, and you do not want to spend an afternoon on it. This guide shows you how to do it with Consentaur in about five minutes, step by step.

Before you start

You need two things:

  • Access to your WordPress admin (usually yoursite.com/wp-admin)
  • A Consentaur account: create one for free (it takes less than a minute)

You do not need to write code, and you do not need a cookie consent plugin. You add one script to your site's header.

Step 1: Create an account and add your site

  1. Sign up for a Consentaur account
  2. In the dashboard, click "Add site"
  3. Enter your website's domain (for example www.yoursite.com)
  4. Consentaur scans your site and lists the cookies it finds

Step 2: Copy your script

Under "Script" in the Consentaur dashboard you will find the script for your site. It looks like this:

<script src="https://cdn.consentaur.com/v1/your-site-id.js"></script>

Copy the whole script tag. You need it in the next step.

Step 3: Add the script to WordPress

There are two ways. Pick the one that suits you:

Option A: a header and footer plugin (recommended)

The easiest option if you would rather not edit theme files, and the one to use with block themes:

  1. Install the free WPCode plugin from the WordPress plugin directory
  2. Go to Code Snippets → Header & Footer
  3. Paste the Consentaur script at the very top of the Header box, above any other scripts
  4. Click "Save Changes"

Option B: directly in a classic theme

If your theme has a header.php file and you prefer not to install a plugin:

  1. Go to Appearance → Theme File Editor in the WordPress admin
  2. Open header.php
  3. Paste the Consentaur script straight after the opening <head> tag, before wp_head()
  4. Click "Update File"

Tip: use a child theme and edit its header.php, so your change is not lost when the theme updates.

Step 4: Tag your tracking scripts

To make a tracking script wait for consent, add a data-cookiebar-category attribute to it. For example:

<!-- Google Analytics -->
<script
  src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"
  data-cookiebar-category="analytics"
></script>

<!-- Meta Pixel -->
<script
  src="https://connect.facebook.net/en_US/fbevents.js"
  data-cookiebar-category="marketing"
></script>

The categories are analytics, marketing and preferences. If a plugin adds the tracking code for you (a Google Analytics or Meta plugin, for example), check its settings for where the code is output, or add the code yourself through WPCode so you can tag it.

Step 5: Check that it works

  1. Open your website in a private or incognito window
  2. The cookie banner should appear with options to accept, reject or customise
  3. Click "Reject all", then check in your browser's developer tools (F12 → Application → Cookies) that only necessary cookies are set
  4. In a new private window, click "Accept all" and check that the analytics and marketing cookies now appear
  5. On the Growth and Business plans you can also follow consent decisions under "Statistics" in the Consentaur dashboard

Step 6: Let visitors change their mind

Visitors must be able to withdraw consent as easily as they gave it. Add a link with the data-cookiebar-settings attribute, for example in a footer widget or menu, and it will reopen the cookie settings:

<a href="#" data-cookiebar-settings>Cookie settings</a>

Common WordPress set-ups

WooCommerce

WooCommerce uses necessary cookies for the basket and checkout, and those are not blocked. If you use remarketing (Meta Pixel, Google Ads), tag those scripts with data-cookiebar-category="marketing".

Google Tag Manager

If Google Tag Manager loads your tracking, you can tag the GTM script with the category of the tags it contains (use marketing if it loads any marketing tags). Or use the Consent Mode v2 signals Consentaur sends, and set the consent requirements for each tag inside GTM.

Elementor and other page builders

Page builders do not affect Consentaur. The script loads in the <head>, whatever you build your pages with, so it works with Elementor, Divi, WPBakery, Beaver Builder and the rest.

Switching from another plugin?

If you already use a cookie consent plugin (Cookie Notice, Complianz, GDPR Cookie Compliance and so on):

  1. If the old plugin kept consent records, export them first: uninstalling a plugin can remove its data
  2. Add the Consentaur script as described above
  3. Deactivate and remove the old plugin
  4. Test everything in a private window

Consentaur starts recording consent decisions as soon as the script is live.

Frequently asked questions

Does Consentaur work with every WordPress theme?

Yes. Consentaur is an external script that runs independently of your theme, so it works with any theme, with page builders such as Elementor, Divi and WPBakery, and with WooCommerce.

Can I use Consentaur alongside other plugins?

Yes. It replaces other cookie consent plugins, though, so deactivate those to avoid showing two banners.

Do caching and optimisation plugins cause problems?

Page caching is fine: the script is loaded from our CDN. If your optimisation plugin defers, delays or combines JavaScript (WP Rocket, LiteSpeed Cache and similar plugins offer this), exclude the Consentaur script. It has to load first, without async or defer, to block other scripts in time.

Does it work with WooCommerce?

Yes. The cookies WooCommerce needs for the basket and checkout are necessary cookies and are not blocked, so your shop works as normal. Tracking scripts you tag as analytics or marketing wait for the customer's consent.

Ready to get started?

Create a free Consentaur account and have cookie consent on your WordPress site in about five minutes.

Start your free trial

14-day free trial. No credit card required.