Callback & Events
Customise the user’s experience programmatically.
Event Broadcasts
You can use this to read user’s consent to cookie categories and services. View our docs on Consent Callbacks & Events ›
Consent Callbacks
cc:onFirstConsent
Triggered the first time user expresses their choice of consent (accept/reject).
cc:onConsent
This event is triggered the very first time the user expresses their choice of consent — just like onFirstConsent
— but also on every subsequent page load.
cc:onChange
This event is triggered when the user modifies their preferences and only if consent has already been provided.
Modal Callbacks
cc:onModalShow
The consent modal is visible.
cc:onModalHide
The consent modal is hidden.
cc:onModalReady
The consent modal is created and appended to the DOM.
Actions
show
Shows the consent banner. If consent was previously expressed, the consent modal will not be generated; you’ll have to pass the argument true
to generate it on the fly.
hide
Hides the consent banner.
showPreferences
Shows the preferences modal.
hidePreferences
Hides the preferences modal.
acceptCategory
Programmatically accept or reject a cookie category.
acceptedCategory
Returns true
if the specified category was accepted, otherwise false
.
acceptService
Accepts or rejects services.
acceptedService
Returns true
if the specified service was accepted, otherwise false
.
validConsent
Returns true
if consent is valid.
Consent is NOT valid when at least one of following situations occurs:
- consent is missing (e.g. user has not yet made a choice)
- CookieChimp’s cookie does not exist/has expired
- CookieChimp’s cookie is structurally not valid (e.g. empty)
getUserPreferences
Returns user’s preferences of accepted/rejected categories and services.
Type: function(): object
Possible acceptType values:
'all'
'custom'
'necessary'
reset
Resets CookieConsent by dropping all internal pointers and config. You can pass the argument true
to delete CookieChimp’s cookie which holds the user’s consent & preferences. The user will be prompted again to express their consent.
Once this method is called, CookieChimp won’t be functional on the page. The webpage needs to be fully reloaded to re-initialise CookieChimp.