Skip to content

Cookifi events

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.

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

Both events expose the current consent state via event.detail:

{
marketing: boolean,
analytics: boolean,
preferences: boolean
}
window.addEventListener('cookifiOnConsentLoad', function (e) {
if (e.detail?.analytics) {
// initiate analytics
} else {
// disable analytics
});