-
Notifications
You must be signed in to change notification settings - Fork 27
WP Core Consent Level API
Nearly 2 years ago we asked for an API that could signal the users consent state to other plugins. It is now in development.
https://core.trac.wordpress.org/ticket/44043
To support the new WP Core Consent Level API.
Our integration should only be concerned about signaling the consent state to the API. This can be done through Javascript.
Methods available on the consent API: https://github.com/rlankhorst/wp-consent-level-api/
Cookiebot publishes different events that we need to add custom event listeners for.
Event | Description |
---|---|
CookiebotOnAccept | The event is triggered if the user accepts the use of cookies. The event is also triggered if the user has consented at an earlier visit to the website. |
CookiebotOnDecline | The event is triggered if the user declines the use of cookies by clicking the decline-button in the cookie consent dialog. The event is also triggered if the user already has declined at an earlier visit to the website. |
Whenever one of these events are published, we shall compare the consent state on the CookieConsent object with the consent state in the Consent Level API. If there are any changes, we have to update the Consent Level API to reflect the current consent state.
Because above events may be fired on every page load we need to compare the values so that the Consent Level API is not signaling the same consent state all the time.
Following properties on the CookieConsent object may be of use:
Name | Type | Default | Description |
---|---|---|---|
consent.necessary | bool | true | True if current user has accepted necessary cookies. The property is read only. |
consent.preferences | bool | false | True if current user has accepted preference cookies. The property is read only. |
consent.statistics | bool | false | True if current user has accepted statistics cookies. The property is read only. |
consent.marketing | bool | false | True if current user has accepted marketing cookies. The property is read only. |
consented | bool | false | True if the user has accepted cookies. The property is read only. |
declined | bool | false | True if the user has declined the use of cookies. The property is read only. |
More information about the Cookiebot API is available here: https://www.cookiebot.com/en/developer/
Cookiebot works with 3 categories while the Consent Level API works with 4.
Following is the default mapping of the categories:
Cookiebot | Wordpress |
---|---|
Necessary | Functional |
Preferences | Preferences |
Statistics | Statistics |
Statistics | Statistics-anonymous |
Marketing | Marketing |
The above mappings should be editable in the plugin backend, under Advanced Settings.
The above mappings should only be editable/visible if the Consent Level API is installed.
Developers should figure out a UI that is easy to comprehend and use for mapping the categories.