Back|
C
Cookiestack
Sign inGet started

JavaScript API

Last updated: September 8, 2026

There's no separate SDK or npm package — the entire programmatic surface is one global object and one DOM event.

window.__cb

Once initialized, the widget stores the current configuration and consent state on window.__cb:

window.__cb.config   // current banner configuration
window.__cb.consent  // current consent state (set once
                      // the visitor has made a decision)

consent has boolean necessary, preferences, statistics, marketing fields, plus action, timestamp, version. Note that window.__cb is populated asynchronously after the config loads from the server — don't read it synchronously right after the script tag; use the event below instead.

Blocking your own scripts

To stop a third-party tracker from running before consent, mark its tag inert — browsers never execute <script type="text/plain"> — and tag it with the category that should unblock it:

<script
  type="text/plain"
  data-cookie-category="marketing"
  src="https://example.com/pixel.js"
></script>

Valid categories: preferences, statistics, marketing (necessary is always unblocked). The widget watches for these tags with a MutationObserver, so this also works for tags added to the DOM later — by another script or a tag manager — not just ones present in the initial HTML. The mechanism is gated by the autoBlock setting in banner configuration.

Next

Cookiestack Widget JavaScript API