-
Notifications
You must be signed in to change notification settings - Fork 0
Javascript API
Opens the cookie notice (modal or banner)
cookiefox.api.show()
<a href="javascript:void(0)" onclick="cookiefox.api.show()">Open Privacy Settings</a>
Returns the user consent as an object of categories (category consent mode) or a boolean value (single consent mode). Can also be null
if consent is not yet initialized
cookiefox.api.getConsent()
let consent = cookiefox.api.getConsent()
categories: {functional: true, statistics: true, marketing: true, external-media: true}
Sets the consent (true, false) in CookieFox. A category parameter must be present if the category consent mode is used - omit in single consent mode.
cookiefox.api.setConsent(consent)
cookiefox.api.setConsent(consent, category)
cookiefox.api.setConsent(true)
cookiefox.api.setConsent(true, 'marketing')
cookiefox.api.setConsent(false, 'statistics')
Is triggered after Cookiefox is initialised
cookiefox:init
document.addEventListener("cookiefox:init", function(){ console.log("Cookiefox Initialized"); });
Is triggered after Cookiefox consent has been changed. This happens everytime the cookie notice is closed and once after the initial page load. This event should be used to watch consent changes. The consent (see getConsent()
api) is returned in the detail property of the event object.
cookiefox:consent-changed
document.addEventListener("cookiefox:consent-changed", function(e){ console.log("Cookiefox Consent Changed", e.detail); });