Developers

Documentation

Everything to install Consorm, manage consent and integrate your tools, from the first script to exporting the records.

Banner

The JavaScript API

Control the banner from your code: reopen the preferences, read the consent state and react to decisions through the dataLayer.

Once loaded, the banner exposes a global window.__cmp object on every page. It lets you open the banner or the preference center from your own interface elements and read the current consent state: useful, for example, for a "Manage my cookies" link in your footer.

Methods

MethodEffect
__cmp.showPreferences()Opens the preference center, where the visitor changes or withdraws their consent.
__cmp.showBanner()Shows the initial consent notice again.
__cmp.hideBanner()Hides the displayed notice.
A "Manage my cookies" link in your footer
<a href="#" onclick="window.__cmp && __cmp.showPreferences(); return false;">
  Manage my cookies
</a>

The banner may not be loaded yet

The script loads asynchronously: always test for the presence of window.__cmp (and its ready property) before calling a method, as in the example above.

Reading the consent state

The __cmp object also carries the current state, read-only:

PropertyContent
__cmp.consentThe per-category state, for example { necessary: true, analytics: true, advertisement: false }.
__cmp.catsThe categories configured for the site.
__cmp.readytrue when the banner is initialized.
__cmp.regimeThe consent regime applied to the visitor according to their location.
__cmp.gpcAppliedtrue if a Global Privacy Control signal was honored.
Example: show a module only if analytics is consented
if (window.__cmp && __cmp.ready && __cmp.consent.analytics) {
  // the visitor accepted the Analytics category
  loadMyModule();
}

The visitor's decision is kept in a single first-party cookie, csm_consent, valid for 365 days, set with SameSite=Lax; Secure on your site's registrable domain (so it also applies to your subdomains). Its value is an encoded JSON object:

FieldMeaning
idThe visitor's consent identifier (csm_ prefix), the one that appears in the record.
vThe version of the configuration published at the time of the choice.
cThe per-category detail (true / false).
aThe action: accept_all, reject_all, save_preferences or withdraw.
tThe decision's timestamp (milliseconds since the epoch).

Reacting to decisions (dataLayer)

There is no callback subscription API: the integration goes through Google Tag Manager. On every decision, the banner pushes the Consent Mode update and the csm_consent_update event into the dataLayer. Create a custom event trigger on that name to fire a tag as soon as a visitor consents: it is exactly how the GA4 and Meta tags of the automatic installation re-fire without a reload.

What the banner pushes after a decision (simplified)
window.dataLayer.push(["consent", "update", {
  analytics_storage: "granted",
  ad_storage: "denied",
  ad_user_data: "denied",
  ad_personalization: "denied",
  /* … every Consent Mode v2 signal */
}]);
window.dataLayer.push({ event: "csm_consent_update" });