Cookifi events
What it is
Section titled “What it is”Cookifi exposes custom browser events that allow you to react to consent changes in real time. You can listen to these events and conditionally initialise or disable scripts (such as analytics or marketing tags) based on the visitor’s consent choices.
Available events
Section titled “Available events”cookifiOnConsentLoad
Fires when Cookifi loads and resolves the visitor’s consent state.
This includes:
- The initial consent state applied on page load
- Updated consent state after the visitor interacts with the banner and saves their preferences
The event provides consent values for:
- marketing
- analytics
- preferences
cookifiOnConsentUpdate
- Fires whenever the visitor actively changes their consent preferences (for example, by interacting with the consent banner or preference centre).
- marketing / analytics / preferences
The event provides updated consent values for:
- marketing
- analytics
- preferences
Event payload
Section titled “Event payload”Both events expose the current consent state via event.detail:
{ marketing: boolean, analytics: boolean, preferences: boolean}Example
Section titled “Example”window.addEventListener('cookifiOnConsentLoad', function (e) { if (e.detail?.analytics) { // initiate analytics } else { // disable analytics});