How-To

Cookie Consent for WordPress: Complete Setup Guide

How to add a GDPR-compliant cookie banner to a WordPress site: plugin install, configuration, script blocking, and caching compatibility — for ConsentTrustee and other CMPs.

Published

Cookie Consent for WordPress: Complete Setup Guide

WordPress powers something like 43% of the public web, so cookie-banner advice that doesn't work on WordPress isn't very useful advice. The good news: WordPress makes this easy. The bad news: it makes it easy in a few different ways and they're not equivalent.

This guide covers the two main install paths (plugin vs script tag), the popular plugin options, caching compatibility, Multisite, and the gotchas that come up in real installs.

Plugin or script tag?

Two ways to get a cookie banner onto a WordPress site:

Plugin route. Install a CMP plugin from the WordPress directory. It handles everything: banner, script blocking, consent log, GCM v2 wiring. You configure via the WordPress admin. Recommended for most sites.

Script tag route. Add a single <script> tag from your CMP's CDN to the <head> of your site. The CMP runs entirely client-side, the WordPress side knows nothing about it. Works with any CMP that provides a JS bundle.

The plugin route gives you tighter integration: the CMP can automatically detect cookies set by other WordPress plugins, the admin UI lives inside your WordPress dashboard, and the consent log can be stored in your WordPress database. The script tag route is simpler and works regardless of your theme, but you'll manage the CMP in a separate dashboard.

ConsentTrustee supports both. Most teams pick the plugin route the first time and switch to the script tag only if they have unusual requirements (multiple WP sites sharing one CMP config, for example).

Installing the plugin

Standard WordPress plugin install:

  1. WordPress admin → Plugins → Add New.
  2. Search for “ConsentTrustee” (or your CMP of choice).
  3. Click Install Now, then Activate.
  4. Find the new menu item in your admin sidebar (usually under Settings).
  5. Paste your domain slug from the CMP dashboard.
  6. Toggle the categories you want to enable (Necessary, Preferences, Statistics, Marketing).
  7. Optionally enable Google Consent Mode v2 if you run Google tags.
  8. Save and visit your site in an incognito window to verify the banner shows.

For ConsentTrustee specifically, you get the WordPress plugin here. Install takes about two minutes.

The popular plugins, briefly

CookieYes. The default choice for WordPress beginners. Free tier covers basic needs. Active install count over 1.5M as of 2026. Limitations on the free tier: no GCM v2 full automation, no consent log export, scan depth is shallow.

Complianz. Strong on EU-specific compliance. Geo-targeting and TCF support included even on lower tiers. UI is dated but the underlying compliance work is solid. Around 700k active installs.

Real Cookie Banner. German-built, heavily focused on GDPR specifics. Excellent script-blocking and a built-in cookie scanner. Premium-only for most features, free version is limited.

GDPR Cookie Compliance. Older but stable. Lightweight, no scanner, manual cookie categorisation. Works for small sites without a marketing stack.

ConsentTrustee. Our plugin. Lightweight (13KB runtime, smallest in the comparison), GCM v2 included, GPC honour, free tier covers 50 subpages. Bias acknowledged.

The script tag route

If you'd rather not install a plugin, drop a script tag in your theme's header.php or use a header-injection plugin like Insert Headers and Footers or WPCode:

<script
  src="https://cdn.consenttrustee.com/consenttrustee.js"
  data-domain="your-domain-slug"
  async
></script>

Replace your-domain-slug with the slug from your ConsentTrustee dashboard, not your site's address.

For tracking scripts that need consent gating, change their loading method so the browser doesn't execute them until the visitor accepts. The standard approach is to swap type="text/javascript" for type="text/plain" and add a data-ct-category attribute:

<script
  type="text/plain"
  data-ct-category="statistics"
  src="https://www.googletagmanager.com/gtag/js?id=G-XXXXX"
></script>

The CMP runtime swaps the type to text/javascript once the visitor accepts the matching category, at which point the browser loads and runs the script.

Caching compatibility

The biggest worry teams have with WordPress cookie banners is caching plugins serving stale consent state to logged-in visitors. In practice this is almost never a problem because cookie banners are client-side: the banner UI, the consent check, and the script unblocking all happen in the visitor's browser using localStorage. The cached HTML page is the same for everyone; the banner state is per-visitor.

Specific notes on the major cache plugins:

  • WP Rocket. Works fine out of the box. If you use WP Rocket's lazy-load for JS, exclude the CMP script from lazy-loading so it's present before the banner renders.
  • W3 Total Cache. Works fine. Don't minify the CMP script (it's already minified by the vendor and re-minification occasionally breaks edge cases).
  • WP Super Cache. Works fine. Page caching ignores the CMP entirely.
  • LiteSpeed Cache / Cloudflare APO. Works fine. The cookie that stores consent (ct_consent) shouldn't be added to the cache key.

Multisite

WordPress Multisite is a network of sites under one WordPress install. Each site usually has its own domain, content, and users. For CMP purposes, each subsite is treated as a separate domain in your CMP dashboard, with its own consent log and configuration.

Most cookie-banner plugins support Multisite by activating per-site. ConsentTrustee's plugin lets you either configure each subsite individually or apply a network-wide default and override per-site.

Common WordPress gotchas

Google Analytics for WP plugins. Plugins like MonsterInsights or ExactMetrics inject the GA snippet themselves. If you let them, they fire before consent. Most have a “consent mode” toggle now; turn it on, or disable the plugin's GA injection and let your CMP handle the tag.

WooCommerce. Adds its own tracking via Facebook for WooCommerce, Google Listings & Ads, etc. Each of these needs to be tied to consent. See the WooCommerce-specific guide for the auto-mapping setup.

Page builders (Elementor, Divi). Sometimes inject third-party scripts at page-level, not site-level. Check each page's third-party widgets and make sure those scripts also go through consent.

JetPack stats. WordPress.com's built-in analytics sets first-party cookies but is still subject to ePrivacy. Categorise as Statistics and let the CMP gate it.

What I'd read next

For the legal context that makes the banner necessary, GDPR Cookie Consent. For the technical pattern your CMP uses to block scripts, How to Block Third-Party Scripts Until Consent. For WooCommerce stores specifically, Cookie Consent for WooCommerce.