Integrations
WordPressWordPress
field-testedPlatforms and stores

Cookie banner for WordPress with Consent Mode v2 and tracker blocking

Add CookiePilot to WordPress without editing the theme. The plugin handles the cookie banner, Consent Mode v2, domain key and basic tracker checks on the public site.

Overview

Add CookiePilot to WordPress without editing the theme. The plugin handles the cookie banner, Consent Mode v2, domain key and basic tracker checks on the public site.

Info

Configuration from the WordPress admin.

Info

Domain key and banner settings are synced.

Info

Safe default consent values for Google Consent Mode.

Consent behaviour

window.CookiePilot is available on the frontend.

Before consent there are no _ga, _fbp, _gcl or similar cookies.

Reject keeps the site functional.

Accept sends the consent update to dataLayer.

Setup steps

Install and activate the CookiePilot plugin.

Paste the domain key from CookiePilot.

Enable Consent Mode v2 and save the configuration.

Open the frontend in a clean session and verify the banner before consent.

Example snippet

Example snippet

Example snippet
<?php
// Example: load an extra script only after CookiePilot grants marketing consent.
add_action('wp_footer', function () {
    ?>
    <script>
    window.addEventListener('cookiepilot:consent', function (event) {
      var consent = event.detail || {};
      if (!consent.marketing) return;

      var script = document.createElement('script');
      script.src = 'https://example.com/marketing-tag.js';
      script.async = true;
      document.head.appendChild(script);
    });
    </script>
    <?php
}, 30);

// Browser console checks on a clean, logged-out WordPress visit
window.CookiePilot
CookiePilot.getConsent && CookiePilot.getConsent()
document.cookie.split('; ').filter(function (cookie) {
  return /(_ga|_fbp|_gcl|_hj|_ttp)/.test(cookie);
})

Test checklist

window.CookiePilot is available on the frontend.

Before consent there are no _ga, _fbp, _gcl or similar cookies.

Reject keeps the site functional.

Accept sends the consent update to dataLayer.

Setup steps

  1. 1Install and activate the CookiePilot plugin.
  2. 2Paste the domain key from CookiePilot.
  3. 3Enable Consent Mode v2 and save the configuration.
  4. 4Open the frontend in a clean session and verify the banner before consent.

Test checklist

  • window.CookiePilot is available on the frontend.
  • Before consent there are no _ga, _fbp, _gcl or similar cookies.
  • Reject keeps the site functional.
  • Accept sends the consent update to dataLayer.

FAQ

Is this legal advice?

No. It is an implementation guide. For unusual data flows, confirm the setup with your legal or privacy team.

Does CookiePilot block every script automatically?

CookiePilot supports autoblocking and Consent Mode. Trackers hardcoded before the CMP still need to be moved behind the stub or into GTM Consent Initialization.

Related integrations

See the setups that most often appear together with this integration.

Ready to configure it?

Start CookiePilot, choose the right integration and verify that tags wait for user consent before they run.