|
/ Documentation /Integrations/ WP Consent API Compatibility

WP Consent API Compatibility

Your consent banner is not the only plugin on your site that cares about consent. Statistics, marketing and e-commerce plugins each need to know whether a visitor agreed to tracking. Without a shared standard, each one has to guess. The WP Consent API is the WordPress standard that fixes this: one plugin manages consent, and every plugin that supports the standard reads it.

When the WP Consent API plugin is active, SureCookie registers itself as your site’s consent manager and shares each visitor’s choices with it. Plugins that support the standard then follow your SureCookie banner. Supporting plugins need no extra setup, and they get each new choice as soon as the visitor makes it. This integration is part of the free plugin.

Set Up the Integration

There is no setting for this integration inside SureCookie. It turns on by itself when the WP Consent API plugin is active.

  1. Install and activate the WP Consent API plugin from the WordPress.org plugin directory.
  2. Go to SureCookie → Settings → Banner → Content.
  3. Check that Enable Cookie Banner is on.

The other plugins on your site benefit only if they support the WP Consent API too. Check each plugin’s documentation to confirm.

Note: Use SureCookie 1.5.0 or later. In earlier versions, plugins that read consent on the server were told nothing until a visitor clicked the banner.

How Categories Map

The WP Consent API uses its own names for consent types. SureCookie translates your categories automatically.

SureCookie CategoryWP Consent API Type
Essential Cookiesfunctional
Functional Cookiespreferences
Analytics Cookiesstatistics
Marketing Cookiesmarketing
Uncategorized Cookiesmarketing
Custom categories you addmarketing

SureCookie shares four of the API’s types: functional, preferences, statistics and marketing. By default, it does not set the API’s statistics-anonymous type (see For Developers below).

Two details are worth knowing:

  • Essential Is Always Allowed – Strictly necessary cookies do not need consent, so the functional type always reads as allowed, whatever the visitor chose.
  • Marketing Cookies Decides the Marketing Type – The API holds one answer per type. Uncategorized and custom categories share the marketing type with Marketing Cookies, and the visitor’s Marketing Cookies choice decides it. A visitor who accepts Marketing Cookies but declines one of your custom categories still reads as allowed for marketing.

To add or review your own categories, see Manage Cookie Categories.

For Developers

The surecookie_wp_consent_api_category_map filter changes the type for custom and Uncategorized categories only. The four built-in categories always keep the mapping above. Pointing a custom category at a type a built-in category already uses has no effect, because the built-in category’s choice decides that type. Only statistics-anonymous, which no built-in category uses, gives a custom category a signal of its own. See Developer Reference: Hooks & Filters.

What the API Reports Before a Choice

Until a visitor responds to the banner, SureCookie reports the consent model that applies to them:

  • Opt-in – functional reads as allowed. preferences, statistics and marketing read as denied.
  • Opt-out – Every type reads as allowed until the visitor declines.

Out of the box, SureCookie uses opt-in for every visitor.

With Geographic Rules

Geographic Rules is a SureCookie Pro feature, set under SureCookie → Tracking Manager → Geographic Rules. When you choose Show only where required by law, visitors in a targeted region get that region’s consent model in the API. To set up regions, see How to Set Up Geographic Targeting.

How It Works

SureCookie shares consent in the two places other plugins look for it:

  • In the browser – Each choice goes to the API as the visitor makes it, and again on every page load. Scripts that listen for consent changes can react without a reload.
  • On the server – Once WordPress has finished loading, SureCookie reads the visitor’s stored choice and answers consent checks from other plugins in that same request, such as a call to wp_has_consent() while the page is built. A check made earlier, during plugins_loaded or init, does not get SureCookie’s answer yet. If a full-page cache serves the page, that answer is cached with it, so a plugin that needs each visitor’s own answer should read consent in the browser. See Compatibility: Caching Plugins & Page Builders.

What It Does Not Replace

The WP Consent API is a communication standard, not an enforcement tool. A plugin that ignores the standard still sets its cookies. SureCookie’s Block Scripts Until Consent handles those: it holds scripts and embeds on the page until the visitor consents, whether or not they support the API.

Use both together. The API covers plugins that cooperate, and blocking covers everything else.

Troubleshooting

  • A plugin still sets cookies before consent – It probably does not support the WP Consent API. Block it instead under SureCookie → Tracking Manager → Scripts and Embeds.
  • You are not sure the integration is active – It runs only while the WP Consent API plugin is active. Check Plugins → Installed Plugins, then confirm Enable Cookie Banner is on.
  • A supporting plugin stays off before visitors choose – This is the opt-in default. The API reports consent once the visitor accepts the matching category.
  • A plugin runs after a visitor declined a custom category – Custom categories share the marketing type, so the visitor’s Marketing Cookies choice decides it. See How Categories Map above.

Next Steps

To hold back plugins that do not support the standard, see Resource / Script Blocking (Add Embeds + Fixes). To understand the defaults the API reports, see Consent Models Explained (Opt-in vs Opt-out).

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Table of Contents
Scroll to Top