Skip to main content

Event Mapping

Mapping is used to configure and translate walkerOS events for destinations. It defines if and how to process events, by renaming, structuring, bundling, or ignoring them. It's also checking for consent and validate values.

Config

Besides the destinations general configuration, a mapping config is set to process events individually. The EventConfig is defined as { [entity]: { [action]: EventConfig }}.

A generic "*" can be used to match all entities and/or actions that are not explicitly matched.

{
// Config
[entity]: {
[action]: {
// EventConfig
name: "event name",
data: {
// ValueConfig
}
}
}
}

Example

Event
Custom Config
Result

Change the event name to order visible and see how the batched mapping is applied after 1 second.

EventConfig

The Destination.Event mapping for each event supports standardized default options. The custom option can be used to set up custom properties for the event and destination's individual settings.

PropertyValueDescription
namestringRenaming of the event (e.g. product add to add_to_cart)
dataobjectHow to transform the event data.
ignorebooleanIf set to true the event won't get pushed to the destination.
conditionfunctionA function to check if the mapping should be used.
consentobjectRequired states to process the event.
customobjectIndividual settings for a custom destination.
batchnumberTime in ms to bundle the events before calling pushBatch if available.

To disable processing of other events, add {'*': {'*': { ignore: true }}} to the mapping.

The destination event mapping technically uses the mapping utils to create the desired event structure. And the getByPath dot notation to access event properties (e.g. event.data.total).

name

The name property is used to rename the event. It overrides the original event name.

Event
Custom Config
Result

Example: A walkerOS order complete usually becomes a purchase event in GA4 or an order event in Piwik PRO.

data

The data property is used to transform the event data. It fully describes the data structure for the destination. See ValueConfig for detailed usage.

Event
Custom Config
Result

ignore

Event
Custom Config
Result

The ignore property is used to ignore the event. If set to true, the event won't get pushed to the destination.

The consent property is used to require a specific state to process the event.

custom

The custom property is used for individual destination settings. In most cases the data property is enough. But in special cases a custom mapping might simplify the configuration.

batch

The batch property is used to bundle the events before pushing them to the destination. A destination must offer a pushBatch method to use this feature. The pushed event(s) are an object with the following properties:

  • key: Name of the used mapping rule
  • events: An array of the actual events
  • data: The transformed event data
Event
Custom Config
Result

ValueConfig

The data property is used to transform the event data. It is used to create the required data structure for the destination.

It can create any structure of data. With support for recursive data structures.

key

A key accesses a property from the event context.

Event
Data config
Result

string

A simple string is short for {key: 'value'}. And accesses a property from the event context.

Event
Data config
Result

value

Used for creating a static value. Can also be used as a fallback if no other mapping resolves a value.

Event
Data config
Result

map

Used to create an object. The keys are the property names and the values are again a ValueConfig resolving to a value.

Event
Data config
Result

set

Used to create an array of fixed values. Each item is a ValueConfig resolving to a WalkerOS.Property.

Event
Data config
Result

loop

Loops over the first parameter and maps the second to the current value. It is used for creating an array of dynamic length. Use this to loop over the current event.

Event
Data config
Result

condition

Is a function to check if the mapping should be used. It returns a boolean, if it's true the mapping will be used.

Event
Data config
Result

Some values may require an explicit consent state. It can be used to redact values and protect a users privacy by hiding information.

Event
Data config
Result

This can be used to e.g. redact PII like clickIds from a session start event.

fn

A function that returns the value. It receives the current event context, the mapping configuration and the options about the current instance with additional properties as parameters.

Event
Data config
Result

validate

A final check to validate the value. After key, loop, map or set resolved the value, it will be validated with the validate function.

Event
Data config
Result

Execution order

If the data property is an array, the mappings will be executed in the order until a first value is resolved. Usually, a condition is used to check if the mapping should be used. If permission is denied, the static default value would be returned. Then the consent checks if the user granted permission to process the event or value. First, value is used to set the static/default value. Next, fn gets executed. Then a given key or string. If set, either loop, map or loop, map or set is processed. After that, the value gets checked with the validate function. Finally, the value is casted to the correct type. If the validation or casting fails, the value will be either the static default value or the next mapping would be used or ultimately undefined.

tip

Use hooks to modify events before processing.

info

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