WP Consent API Integration
|
Applies to: WordPress Plugin v3.1.0+ WP Admin: Compliance > Cookie Consent tab > Technical Settings > WP Consent API |
Overview
From v3.1.0 onward, Cookie Compliance for WordPress registers as a Consent Management Platform (CMP) for the WP Consent API. This means cooperative WordPress plugins (WooCommerce, Google Site Kit, Burst Statistics, and others) can read the visitor’s banner choice directly from a standard WordPress API, without you having to write any custom “trust the banner” snippets.
The integration is on by default. For most sites, you do not need to change anything — cooperative plugins start respecting consent automatically as soon as the WP Consent API plugin is active.
How It Works
- You install the WP Consent API plugin (free, from WordPress.org). This plugin provides a shared vocabulary — functions like
wp_has_consent('marketing')and constants likeWP_CONSENT_API_CONSENT_TYPE— that every cooperative plugin agrees to use. - Cookie Compliance registers itself as the active CMP. On activation, Cookie Compliance v3.1.0+ tells the WP Consent API plugin: “I am handling consent on this site.” It also declares which consent categories it supports (functional, statistics, statistics-anonymous, marketing, preferences).
- The visitor sees the banner and makes a choice. Cookie Compliance writes the choice into the standard WP Consent API cookie (
wp_consent_...), keyed by category. - Cooperative plugins read the cookie. WooCommerce checks
wp_has_consent('marketing')before enabling Stripe’s analytics features; Site Kit checkswp_has_consent('statistics')before sending pageviews to GA4; Burst reads it before recording anonymous stats. Each plugin self-gates. - Global Privacy Control (GPC) is respected. When the visitor’s browser reports GPC, the banner reports marketing as denied to the WP Consent API. On a site with GPC Support on, it stays denied unless the visitor explicitly chooses to allow Ad Personalization; with GPC Support off, it stays denied for that browser. The banner reads GPC in the browser; the plugin does not read the
Sec-GPCrequest header.
Currently Registered Consumer Plugins
These plugins read consent from the WP Consent API and self-gate when Cookie Compliance is the active CMP:
| Plugin | Gates |
|---|---|
| WooCommerce | Stripe analytics, PayPal analytics, marketing add-ons |
| Google Site Kit | GA4, AdSense, Tag Manager, Search Console |
| Burst Statistics | Anonymous and cookie-based statistics |
| WP Statistics | First-party visitor tracking |
| Pixel Manager for WooCommerce | Meta, Google Ads, TikTok, Pinterest pixels |
| AddToAny Share Buttons | Social-share network calls |
| AFL UTM Tracker | UTM attribution cookies |
The list grows as the WP Consent API ecosystem expands. For any plugin not on this list, autoblocking and category-based script gating still apply.
Configuration
In the WordPress admin, go to Compliance → Cookie Consent tab → Technical Settings and locate the WP Consent API toggle (classic screen: Cookie Consent Settings section).
- On (default) — Cookie Compliance registers as the CMP and writes consent into the WP Consent API cookie. Recommended.
- Off — Cookie Compliance does not register, and the WP Consent API reports no consent type, so cooperative plugins that rely on
wp_has_consent()treat every category as allowed. Use this only if those plugins gate themselves another way. - WP Consent API plugin missing — In the classic settings screen the toggle is greyed out; in the current screen (connected sites) it stays clickable but has no effect. Install and activate the WP Consent API plugin from WordPress.org.
Category Mapping
The WP Consent API defines five standard categories. Cookie Compliance maps its own purpose categories to them as follows:
| WP Consent API Category | Cookie Compliance Purpose |
|---|---|
functional |
Always granted (essential / strictly necessary) |
statistics-anonymous |
Granted when the visitor allows Site Optimization (included in Balanced and Personalized) |
statistics |
Granted when the visitor allows Site Optimization (included in Balanced and Personalized) |
preferences |
Granted when the visitor allows Content Personalization (included in Balanced and Personalized) |
marketing |
Granted when the visitor allows Ad Personalization (included in Personalized); denied while GPC applies (see above) |
Verifying the Integration
- Open the site in a fresh incognito session.
- Open the browser console (F12) and run:
consent_api.consent_type— should return'optin'if GDPR, UK PECR, LGPD or POPIA is among your selected laws, or'optout'if only CCPA, Other US State Laws or PIPEDA are. It is one value for the whole site and does not change with the visitor’s location.wp_has_consent('functional')— returnstrueonce the visitor has made a choice (on an'optin'site it isfalsebefore that, like every category).wp_has_consent('marketing')— should returnfalsebefore the visitor consents on an'optin'site (on an'optout'site it can returntrueuntil the visitor declines), and update when they make a choice.
- Choose Personalized in the banner (in a browser that does not send GPC) and re-run
wp_has_consent('marketing'). It should now returntrue. - If you have a cooperative plugin installed (Site Kit, WooCommerce, etc.), confirm its dashboard reflects the visitor’s state — for example, Site Kit’s GA4 module should report “consent: granted” events.
Relationship to Google Consent Mode
Google Consent Mode v2 (GCM) and the WP Consent API are independent and complementary paths. Cookie Compliance fires both:
- GCM v2 gates Google-side tag execution —
analytics_storage,ad_storage,ad_user_data,ad_personalization. This works for any GA4, Google Ads, or Floodlight tag, regardless of how it was added. - WP Consent API gates server-side and plugin-level behaviour for cooperative consumer plugins.
If you use Site Kit as the source of your GA4 tag, both paths run: GCM tells the Google tag what consent state to operate under, and the WP Consent API tells Site Kit itself whether to even send the request. Both must be configured correctly. See the GTM / Tag Trigger Timing Troubleshooting article for the Site Kit-specific scenario.
Troubleshooting
The WP Consent API toggle is greyed out (or has no effect)
The WP Consent API plugin is not installed or not active. The classic settings screen greys the toggle out; the current screen (connected sites) leaves it clickable. Install the plugin from WordPress.org and activate it.
Cooperative plugin still fires before consent
Check the toggle is on, then check the plugin’s own settings. Some plugins (Site Kit, Burst) have their own “Consent Management” section that may need to be set to “Use a CMP” rather than “Always allow”. See the per-plugin troubleshooting in Autoblocking Not Working — Troubleshooting.
I had a manual “push consent into [plugin]” snippet from an older version
Remove it. With v3.1.0+ and the WP Consent API plugin active, manual bridges are redundant and can cause double-fires.
I want to opt out of the integration entirely
Turn the WP Consent API toggle off. Cookie Compliance will continue to operate normally; cooperative plugins that rely on wp_has_consent() will then treat every category as allowed.