> Part of the walkerOS documentation. Project overview and full index: <https://www.walkeros.io/llms.txt>

# CookiePro / OneTrust

Integrates [CookiePro / OneTrust](https://www.onetrust.com/) consent management with walkerOS by mapping CookiePro category IDs (`C0001`, `C0002`, ...) to walkerOS consent groups.

## Installation[​](#installation "Direct link to Installation")

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

```
import { startFlow } from '@walkeros/collector';

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



await startFlow({

  sources: {

    consent: {

      code: sourceCookiePro,

    },

  },

});
```

## Configuration[​](#configuration "Direct link to Configuration")

This <!-- -->source<!-- --> uses the standard <!-- -->source<!-- --> config wrapper (consent, data, env, id, ...). For the shared fields see [source<!-- --> configuration](https://www.walkeros.io/docs/sources.md#configuration). Package-specific fields live under `config.settings` and are listed below.

## Settings[​](#settings "Direct link to Settings")

| Property       | Type                     | Description                                                                                       | More |
| -------------- | ------------------------ | ------------------------------------------------------------------------------------------------- | ---- |
| `categoryMap`  | `Record<string, string>` | Map the CMP's consent categories (keys) to walkerOS consent groups (values).                      |      |
| `explicitOnly` | `boolean`                | Only process consent after the user closed the OneTrust banner (IsAlertBoxClosed). Default: true. |      |
| `globalName`   | `string`                 | Custom name for the OneTrust global on window. Default: 'OneTrust'.                               |      |

## Mapping[​](#mapping "Direct link to Mapping")

This package does not define custom rule-level settings. For the standard rule fields (consent, condition, data, batch, name, policy) see [mapping](https://www.walkeros.io/docs/mapping.md).

## Examples

### Category map override

Custom categoryMap remaps C0002 from analytics to statistics

Event

```
",C0001,C0002,"
```

Mapping

```
{
  "categoryMap": {
    "C0002": "statistics"
  }
}
```

Out

```
elb("walker consent", {
  "functional": true,
  "statistics": true,
  "marketing": false
})
```

### Full consent

A CookiePro OptanonConsent cookie listing all groups is translated into a walker consent command with all true.

Event

```
",C0001,C0002,C0003,C0004,C0005,"
```

Out

```
elb("walker consent", {
  "functional": true,
  "analytics": true,
  "marketing": true
})
```

### Minimal consent

Only the necessary CookiePro group is granted so analytics and marketing map to false in the walker consent command.

Event

```
",C0001,"
```

Out

```
elb("walker consent", {
  "functional": true,
  "analytics": false,
  "marketing": false
})
```

### SDK loaded detection

Immediate detection when OneTrust SDK is already loaded with IsAlertBoxClosed() = true

Event

```
",C0001,C0003,C0004,"
```

Out

```
elb("walker consent", {
  "functional": true,
  "analytics": false,
  "marketing": true
})
```

## How it works[​](#how-it-works "Direct link to 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.

### CookiePro categories[​](#cookiepro-categories "Direct link to CookiePro categories")

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

![CookiePro categorizations](/assets/images/cookiepro-categorizations-f51a6f89c20bf03ee21163b913637225.png)

### Default category mapping[​](#default-category-mapping "Direct link to 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[​](#custom-mapping-example "Direct link to Custom mapping example")

```
await startFlow({

  sources: {

    consent: {

      code: sourceCookiePro,

      config: {

        settings: {

          categoryMap: {

            C0002: 'statistics', // Use 'statistics' instead of 'analytics'

          },

          explicitOnly: true,

        },

      },

    },

  },

});
```

### Timing considerations[​](#timing-considerations "Direct link to 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[​](#reference "Direct link to Reference")

* [OneTrust SDK documentation](https://my.onetrust.com/s/article/UUID-66bcaaf1-c7ca-5f32-6760-c75a1337c226)
* [Source code](https://github.com/elbwalker/walkerOS/tree/main/packages/web/sources/cmps/cookiepro)
