Skip to main content
Ask your AI

CookieFirst

Integrates CookieFirst consent management with walkerOS by listening for CookieFirst events and translating consent categories to walkerOS consent groups.

Installation​

npm install @walkeros/web-source-cmp-cookiefirst
import { startFlow } from '@walkeros/collector';
import { sourceCookieFirst } from '@walkeros/web-source-cmp-cookiefirst';

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

Configuration​

This source uses the standard source config wrapper (consent, data, env, id, ...). For the shared fields see source configuration. Package-specific fields live under config.settings and are listed below.

Settings​

PropertyTypeDescriptionMore
categoryMapRecord<string, string>Map the CMP's consent categories (keys) to walkerOS consent groups (values).
globalNamestringCustom name for the CookieFirst global on window. Default: 'CookieFirst'.

Mapping​

This package does not define custom rule-level settings. For the standard rule fields (consent, condition, data, batch, name, policy) see mapping.

Examples

Category map override

Custom categoryMap remaps performance to statistics instead of analytics

Event
{
  "necessary": true,
  "functional": false,
  "performance": true,
  "advertising": false
}
Mapping
{
  "settings": {
    "categoryMap": {
      "performance": "statistics"
    }
  }
}
Out
elb("walker consent", {
  "necessary": true,
  "functional": false,
  "statistics": true,
  "marketing": false
})

Stored choice at start

CookieFirst already holds the visitor's choice when the source starts, so the read at init emits it.

Event
{
  "necessary": true,
  "functional": false,
  "performance": false,
  "advertising": true
}
Out
elb("walker consent", {
  "necessary": true,
  "functional": false,
  "analytics": false,
  "marketing": true
})

Full consent

CookieFirst reports all categories granted and the source forwards a walker consent command with all groups true.

Event
{
  "necessary": true,
  "functional": true,
  "performance": true,
  "advertising": true
}
Out
elb("walker consent", {
  "necessary": true,
  "functional": true,
  "analytics": true,
  "marketing": true
})

Partial consent

A partial CookieFirst grant maps analytics and marketing to false in the emitted walker consent command.

Event
{
  "necessary": true,
  "functional": true,
  "performance": false,
  "advertising": false
}
Out
elb("walker consent", {
  "necessary": true,
  "functional": true,
  "analytics": false,
  "marketing": false
})

How it works​

  1. Initialization: Checks if CookieFirst is already loaded and processes existing consent state from window.CookieFirst.consent.

  2. cf_init event: Listens for the cf_init window event and reads window.CookieFirst.consent each time it fires.

  3. cf_consent event: Listens for the cf_consent window event and processes the consent state in its detail.

  4. Consent mapping: Translates CookieFirst categories to walkerOS consent groups and calls elb('walker consent', state).

Default category mapping​

{
functional: 'functional',
performance: 'analytics',
advertising: 'marketing',
}

necessary has no entry and is reported as necessary: strictly necessary cookies need no consent, so they grant no consent group, and functional follows the visitor's choice for the functional category. Categories missing from categoryMap are reported under their CookieFirst name.

When several categories map to the same group, the group is true only if every one of them is granted: any deny denies. Category names are compared case-insensitively.

The source reports nothing while window.CookieFirst.consent is null, that is until the visitor has made a choice.

Custom mapping example​

await startFlow({
sources: {
consent: {
code: sourceCookieFirst,
config: {
settings: {
categoryMap: {
performance: 'statistics', // Use 'statistics' instead of 'analytics'
},
},
},
},
},
});

Reference​

💡 Need implementation support?
elbwalker offers hands-on support: setup review, measurement planning, destination mapping, and live troubleshooting. Book a 2-hour session (€399)