Skip to main content

CookiePro / OneTrust

Installation

npm install @walkeros/web-source-cmp-cookiepro

Usage

import { startFlow } from '@walkeros/collector';
import { sourceCookiePro } from '@walkeros/web-source-cmp-cookiepro';

await startFlow({
sources: {
consent: {
code: sourceCookiePro,
},
},
});

Settings

SettingTypeDefaultDescription
categoryMapRecord<string, string>See belowMaps CookiePro category IDs to walkerOS groups
explicitOnlybooleantrueOnly process explicit consent (user made a choice)
globalNamestring'OneTrust'Custom name for window.OneTrust object

CookiePro categories

CookiePro registers cookies and assigns them to categories. Those categories are mapped to walkerOS consent groups:

CookiePro categorizations

Default category mapping

{
C0001: 'functional', // Strictly Necessary
C0002: 'analytics', // Performance
C0003: 'functional', // Functional
C0004: 'marketing', // Targeting
C0005: 'marketing', // Social Media
}

Category ID comparison is case-insensitive. Unmapped category IDs are ignored since CookiePro's opaque IDs are meaningless without a mapping. All mapped walkerOS groups receive explicit true/false values — absent groups are set to false so destinations know which consent is denied.

Custom entries are merged with the default mapping. Specify only the categories you want to override — all other defaults remain active.

Custom mapping example

await startFlow({
sources: {
consent: {
code: sourceCookiePro,
config: {
settings: {
categoryMap: {
C0002: 'statistics', // Use 'statistics' instead of 'analytics'
},
explicitOnly: true,
},
},
},
},
});

How it works

  1. Already loaded: Checks if window.OneTrust and window.OptanonActiveGroups already exist. If so, processes consent immediately.

  2. OptanonWrapper: If the SDK isn't loaded yet, wraps the global OptanonWrapper callback (preserving any existing wrapper). The wrapper self-unwraps after the first call.

  3. OneTrustGroupsUpdated event: Listens for the OneTrustGroupsUpdated window event, which fires on every consent change.

  4. Parsing: Splits the OptanonActiveGroups comma-separated string, maps category IDs through categoryMap, and calls elb('walker consent', state). Sets explicit false for all mapped groups not in the active list.

Timing considerations

The source handles all timing scenarios:

  • SDK loads before source: The "already loaded" check reads existing consent from OptanonActiveGroups immediately.
  • Source loads before SDK: The OptanonWrapper wrapping intercepts the SDK's init callback.
  • explicitOnly (default): Uses OneTrust.IsAlertBoxClosed() to determine if the user has actively interacted with the consent banner.

Reference

💡 Need Professional Support?
Need professional support with your walkerOS implementation? Check out our services.