Skip to main content

Configuration

The configuration of a destination is set up in config. Call elb('walker destination', { push: console.log }, config); to add the destination to a source. All properties are optional.

Example

{
id: "demo",
custom: { foo: "bar" },
consent: { demo: true },
init: false,
loadScript: false,
mapping: {
// Read more in the mapping section
page: {
view: { name: "pageview" },
},
"*": {
visible: { batch: 2000 },
},
},
policy: {
'data.gclid': { consent: { marketing: true } },
},
queue: true,
verbose: false,
onError: (error) => console.error("demo error", error),
onLog: (message) => console.log("demo log", message),
on: {
// Source-related on-events
consent: [{ marketing: console.log }],
ready: [console.log],
run: [console.log],
session: [console.log],
},
};

Overview of all properties

PropertyValueDescription
idstringA unique key for the destination
consentobjectRequired consent states to init and push events
customunkownUsed for a destination's individual settings
initbooleanIf the destination has been initialized by calling the init method
loadScriptbooleanIf an additional script should be loaded
mappingobjectConfiguration how to transform events (see Mapping)
policybooleanEnriches, validates, and redacts properties from the event (see MappingValue)
queuebooleanDisable processing of previously pushed events
verbosebooleanEnable verbose logging
onErrorfunctionCustom error handler
onLogfunctionCustom log handler
onOn.ConfigRules for on-functions that are triggered on specific events

Methods

A source communicates with a destination through methods. Its also the source's job to check for proper consent, calling the init method or batching events. The only required method is push to send events to the destination.

push

The push method gets called to send events to the destination, along with the config and eventually mapping.

// push function
const push = (event, config, mapping) => {
config.custom.count++;
event.data.count = config.custom.count;
console.log('demo push', { event, config, mapping });
};

// elb("page view");
// Output with the mapping above
// demo log bar
// demo push { event: { data: { count: 1 }, event: 'pageview' }, config: { ... }, mapping: { ... } }

init

init is optional and gets called before pushing events. It's used to eventually load additional scripts or set up the environment. To interrupt further processing, the method must return false.

The walker.js checks the config.init value to see if a destination has been initialized, or not. This way you can add a destination that has already been initialized.

// Optional init function
const init = (config) => {
if (config.verbose) config.onLog(config.custom.foo);
config.custom.count = 0;
};

pushBatch

The pushBatch method is optional and gets called if the event mapping is configured with a batch number to bundle multiple events before sending them to the destination.

const pushBatch = (batch, config, instance) => {
console.log('demo pushBatch', { batch, config });
};

The batch is an object with the key of the used mapping, the events array and the mapping object itself.

// Configuring a destinations mapping with
const mapping = {
'*': {
visible: { batch: 2000 },
},
};

// Calling a matching event two times
elb('product visible');
elb('promotion visible');

// The destinations pushBatch receives the following batch after 2 seconds
batch = {
key: '* visible',
events: [{ event: 'product visible' }, { event: 'promotion visible' }],
mapping: { batch: 2000 },
};

on

The on method is used to set up rules for on-functions that are triggered by the source (individually for walker.js and node).

const on = {
consent: [{ marketing: console.log }],
ready: [console.log],
run: [console.log],
session: [console.log], // walker.js only
};

Once a source triggers an event, the destinations on method gets called. Replace the console.log with your custom function.

Node destinations in walkerOS offer a flexible and efficient way to handle your server-side event data. Whether you're sending data to a cloud-based data warehouse like BigQuery or to a custom API, node destinations make it easy to configure, initialize, and push your events securely. |

Functions

init

Before pushing events to a destination, the node source checks for an available init function and calls it. This asynchronous function returns either false if an error occurs, preventing any events from being processed, or a complete destination config that will be used for pushing events.

push

The node source calls await destination.push([{ event, mapping }], config); to send events to destinations. This function is executed after checking for proper consent settings. Events are processed in parallel, and function supports batching of multiple events. The mapping parameter is optional and allows for custom event configurations.

info

If you need professional support with your walkerOS implementation, check out our services.