PostscriptPostscript Developers
Guides

Consent Management

If you use a Consent Management Platform (CMP), initialize the SDK with consent pending. Events are queued locally until consent is granted or denied.

Setup

<script>
  window.sunrise = window.sunrise || [];
  sunrise.push(['init', {
    propertyId: 'YOUR_PROPERTY_ID',
    consentMode: 'pending'
  }]);
</script>
<script src="https://cdn.postscript.io/v1/sunrise.min.js" async></script>

Updating Consent

When the user makes a choice, update the consent state:

// User grants consent — queued events are flushed
sunrise.push(['setConsent', 'granted']);
 
// User denies consent — queued events are discarded
sunrise.push(['setConsent', 'denied']);

Consent Modes

ModeBehavior
granted (default)Events are sent immediately
pendingEvents are queued locally until consent is updated
deniedNo events are sent; queued events are discarded

Integration Example

With a typical CMP callback:

// Your CMP fires this callback when the user makes a choice
window.onConsentUpdate = function(consent) {
  if (consent.marketing) {
    sunrise.push(['setConsent', 'granted']);
  } else {
    sunrise.push(['setConsent', 'denied']);
  }
};

If no consentMode is set during initialization, the SDK defaults to granted and sends events immediately.