CJM
PixelGDPR & consent

Use the consent APIs

Signatures, parameters, state, and change notifications.

Call these from your banner handlers after Pixel loading. Example choices must reflect the visitor's actual decision.

updateConsent(consent, meta?)

ArgumentRequiredValues
consentYesgranted/denied string, or a signal object.
consent.analyticsStorageNo in object formgranted or denied.
consent.adStorageNo in object formgranted or denied.
consent.adUserDataNo in object formgranted or denied.
consent.adPersonalizationNo in object formgranted or denied.
metaNoProvenance object.
meta.sourceNomanual, iubenda, cookiebot, or tcf.

A string updates all four signals. An object merges supplied fields only; omitted fields remain unchanged. Do not pass pending, unspecified, or booleans. source records provenance and does not connect the provider.

Example: the person accepts statistics only.

window.CJMPixel.updateConsent({
  analyticsStorage: 'granted',
  adStorage: 'denied',
  adUserData: 'denied',
  adPersonalization: 'denied'
}, { source: 'manual' });

To refuse or withdraw all signals:

window.CJMPixel.updateConsent('denied', { source: 'manual' });

For actual full acceptance, use updateConsent('granted', { source: 'manual' }). The function returns no delivery confirmation. If configuration is still loading, the update waits in the initial queue.

getConsentState()

Takes no arguments. Immediately returns:

const exampleState = {
  signals: {
    analyticsStorage: 'granted',
    adStorage: 'denied',
    adUserData: 'denied',
    adPersonalization: 'denied'
  },
  source: 'manual',
  expressedAt: 1788508800000
}

signals always contains all four values; source and expressedAt are optional. expressedAt is a Unix timestamp in milliseconds, not a string. Before initialization, reading may show the undecided state.

onConsentChange(callback)

Required callback receives the same state shape as getConsentState. It runs on real changes, not an identical repeated banner choice. Registration does not invoke it immediately; read the initial state too.

function showCjmConsent(state) {
  console.table(state.signals);
}
showCjmConsent(window.CJMPixel.getConsentState());
window.CJMPixel.onConsentChange(showCjmConsent);

Register once per page load. The public API returns no unsubscribe function. In React, avoid registering on every render.

Use window.CJMPixel.getIdentity() to inspect identifiers; see Custom events. For dashboard provider setup, follow Cookie banners.

On this page