Add a cookie consent banner to WordPress

Cookbook · platform Last verified View raw markdown (for agents)

In short: install the Cookie Compliance for WordPress plugin and connect it with your App ID and App Secret Key (plugin 3.1.12 and older label it App Key). The plugin adds the banner script to every page for you, so no snippet needs pasting into the theme.

You need #

Where it goes #

  1. In wp-admin → Plugins → Add New, search Cookie Compliance (slug cookie-notice on wordpress.org/plugins/cookie-notice/). Install and activate Cookie Compliance.
  2. Open the plugin's admin screen and connect with the App ID and App Secret Key from the Cookie Compliance dashboard Integrations page for that domain. You can also sign in or sign up from the plugin: if the account has apps but none for this site, the plugin (3.1.13 or later) asks which app to use or offers to create one. On plugin 3.1.20 or later, Domain Info on a connected Free site can offer an unused Professional license the account already has: "You have N licenses available — use one for this site." Use the dashboard instead when the site is managed by the network, you are in Network Admin, or this site shares its connection with another site on the network: Account, then Upgrade on the domain, then Use a license. Not yet browser-verified.
  3. Publish (or confirm published) configuration in the Cookie Compliance dashboard. The plugin pulls config on a schedule and via Pull latest settings (Pull Configuration in plugin 3.1.12 and older) — Dashboard changes are not live on the WP site until a pull.
  4. Keep your analytics plugins and tags (Site Kit, MonsterInsights and similar). The banner holds recognised trackers until the visitor chooses, in regions whose rule requires consent first.
  5. Keep a single consent banner. Remove any hand-rolled cookie popup or other CMP in the theme, so visitors see one clear choice.

Banner engine: a new app starts on v2, whether it is created in the dashboard, through MCP, or from the plugin (3.1.13 or later: signup, or a sign-in that creates an app for this site). Connecting an app that already exists keeps that app's engine, and an app switched back to v1 stays on v1. The plugin picks the CDN path from the app's engine on each settings pull, so you do not paste a script URL. When the engine changes, the plugin shows a notice offering to purge the page cache; you can also run Pull latest settings. On a v2 site, the plugin's new admin interface also lets you choose a Standard or Compact banner.

If the Manual Integration snippet is currently pasted into header.php, a custom HTML widget or an "Insert Headers and Footers" plugin, remove that paste and let the plugin place the banner. The dashboard Manual Integration snippet is for non-WordPress sites; on WordPress the plugin adds the config pull, Script blocking engine control and WP Consent API interop.

What the order controls #

The plugin places the banner early in <head>. It holds recognised trackers until the visitor chooses, in regions whose rule requires consent first, and a script you mark data-hu-category="1" is treated as essential. What runs before consent is your decision.

Confirm the result #

Same verification table as the install-banner skill (private window, strictest region or geo off, no preview badge, no tracking cookies before the visitor chooses in a region whose rule requires consent first, allow-all then hu-consent cookie). Extra WordPress checks:

# Check Pass
W1 View source The plugin injected the banner script pair early in <head> (not a theme paste you added). No second, hand-pasted huOptions block.
W2 Plugin connected App ID matches the dashboard domain; the plugin's Domain Info card shows Protection: Active, not Not connected.

Gotchas #

More help #