setComplianceSettings

The setComplianceSettings() method saves the visitor's consent choices from the consent form. Once invoked, Consent Manager triggers a page view, causing all tags requiring specific consent to fire immediately.

Syntax

ppms.cm.api('setComplianceSettings', settings, onFulfilled, onRejected);

Parameters

settings: { consents: Record<string, { status: 0 | 1 }> } (required)

The consent settings object. consents is an object keyed by consent type. Each consent type contains a statusproperty. See Consent status values.

Don't pass updatedAt in settings. If you do, Consent Manager ignores it. Consent Manager sets updatedAt internally when saving the cookie, and only for consent types included in the current setComplianceSettings() call. Consent types not included in the call retain their existing values from the cookie.

onFulfilled: () => void (required)

The fulfillment handler callback.

onRejected: (error: object) => void

The rejection handler callback. If not specified, the error is logged in the console.

Examples

ppms.cm.api(
  'setComplianceSettings',
  {
    consents: {
      analytics: { status: 1 },
      remarketing: { status: 0 }
    }
  },
  function () {
    console.log('Consent settings saved.')
  },
  function (error) {
    console.error(error)
  }
)