Active Cookie Consent Client-Side Implementation

For Experience API implementation, see the API cookie consent guide

Active cookie consent enables your website to tell Dynamic Yield whether a user has consented to cookies, so Dynamic Yield can apply the correct data collection and personalization behavior.

This guide explains the client-side implementation for sites that use the Dynamic Yield script, including consent handling at page load and during runtime. Learn more about active consent in The Dynamic Yield Privacy Center.


Page-load declaration

Set the user's consent status before the Dynamic Yield script loads. The declaration must be included on every page:

DY.userActiveConsent = { accepted: <true | false> };
  • true – User has granted consent
  • false – User has not granted consent or consent status is unknown

This parameter is set to false unless true is actively received. Pass true only if you already have a valid consent signal for the user, such as consent stored by your consent management platform, your own cookie or storage mechanism, or another consent source used by your site.

⚠️

Important: DY.userActiveConsent at runtime

  • Do not update this value at runtime. It's read only during page load.
  • Do not use this value to evaluate consent at runtime. It doesn't reflect later consent updates.

Runtime update

Update the user’s consent status after the script loads:

DYO.ActiveConsent.updateConsentAcceptedStatus(<true | false>);
  • true – User has granted consent
  • false – User has denied consent
⚠️

In addition to setting consent at page load and in your consent banner, implement this API everywhere consent can be updated on your site. This might include account settings, preference centers, footer privacy controls, terms and conditions pages, and other consent-management interfaces.


Verification and enablement

  1. Implement the APIs on your site. They are ignored until active cookie consent is enabled.
  2. In Experience OS › Settings › Data Privacy › Active Cookie Consent, click Preview to experience the site as if active cookie consent is enabled.
  3. After successful verification, contact Dynamic Yield Support to enable active cookie consent.
  4. At any time, check current consent status using:
DYO.ActiveConsent.isUserOptOut() ? 'Consent not granted' : 'Consent granted';


Did this page help you?