Back|
C
Cookiestack
Sign inGet started

Events Reference

Last updated: September 8, 2026

The widget reports the visitor's decision through a single event — cb:consent, dispatched on window.

cb:consent

window.addEventListener("cb:consent", (e) => {
  console.log(e.detail);
  // {
  //   necessary: true,
  //   preferences: false,
  //   statistics: true,
  //   marketing: false,
  //   action: "custom",       // accept_all | reject_all | custom | withdraw
  //   timestamp: 1757317200000,
  //   version: "1"
  // }
});

It fires every time consent is applied, specifically:

  • the visitor clicked "Accept all", "Reject all", or saved a custom choice;
  • on a repeat visit — immediately on load, if a decision is already stored in the browser;
  • automatically, when the visitor's browser sends Do Not Track (with respectDnt enabled);
  • automatically for visitors in opt-out jurisdictions (e.g. California) — consent is set to "everything allowed" immediately, with no banner shown.

Listen for this event when your code needs to react to consent immediately, without polling window.__cb.consent — for example, to reveal a block of personalized content only after marketing consent is given.

You don't need a separate event to block third-party scripts before consent — use the declarative data-cookie-category mechanism described in JavaScript API.

Cookiestack Widget Events Reference