window.consentApi.consent: Check if a given technical information (e.g. HTTP Cookie, LocalStorage, ...) has a consent:
window.consentApi.consent
Example (ES5):
(window.consentApi && window.consentApi.consent("http", "_twitter_sess", ".twitter.com") || Promise.resolve()).then(function() { console.log("Consent for Twitter embed given, do something...!");}); Copy
(window.consentApi && window.consentApi.consent("http", "_twitter_sess", ".twitter.com") || Promise.resolve()).then(function() { console.log("Consent for Twitter embed given, do something...!");});
Example (ES6, TS):
(window.consentApi?.consent("http", "_twitter_sess", ".twitter.com") || Promise.resolve()).then(() => { console.log("Consent for Twitter embed given, do something...!");}); Copy
(window.consentApi?.consent("http", "_twitter_sess", ".twitter.com") || Promise.resolve()).then(() => { console.log("Consent for Twitter embed given, do something...!");});
Since 2.3.0: You can also check for consent by cookie ID (ID in wp_posts, post id):
wp_posts
window.consentApi.consent(15) Copy
window.consentApi.consent(15)
Since 3.4.14: You can also check for consent by service unique name:
window.consentApi.consent("google-analytics-ua") Copy
window.consentApi.consent("google-analytics-ua")
Rest
window.consentApi.consent
: Check if a given technical information (e.g. HTTP Cookie, LocalStorage, ...) has a consent:Example (ES5):
Example (ES6, TS):
Since 2.3.0: You can also check for consent by cookie ID (ID in
wp_posts
, post id):Since 3.4.14: You can also check for consent by service unique name: