Skip to main content

Event Mapping

Event mapping is a core feature of walkerOS that allows you to transform events before they reach destinations. The mapping system provides flexible configuration options to handle different destination requirements while maintaining a consistent event structure.

Overview

The mapping system consists of two main functions:

  • getMappingEvent: Returns the matching event mapping configuration for entity-action events
  • getMappingValue: Processes values from events using flexible mapping configurations

Mapping configurations are defined per destination and allow you to:

  • Transform event names
  • Extract and reshape event data
  • Apply conditional logic
  • Handle consent requirements
  • Validate data before sending

Event Mapping with getMappingEvent

getMappingEvent(event: WalkerOS.PartialEvent, mapping?: Mapping.Rules): Promise<Mapping.Result>

This function finds the appropriate mapping configuration for an event based on its entity and action.

Basic Event Mapping

Map specific entity-action combinations to custom event names:

Configuration
Result

Wildcard Mappings

Use wildcards (*) to match multiple entities or actions:

Configuration
Result

Conditional Mappings

Use conditions to apply different mappings based on event properties:

Configuration
Result

Ignoring Events

Skip processing certain events by setting ignore: true:

Configuration
Result

Value Mapping with getMappingValue

getMappingValue(value: unknown, mapping: Mapping.Data, options?: Mapping.Options): Promise<WalkerOS.Property | undefined>

This function transforms values using various mapping strategies.

String Key Mapping

Use a string to extract a value by its property path:

Configuration
Result

Array Access

Access array elements using dot notation:

Configuration
Result

Static Values

Return static values using the value property:

Configuration
Result

Custom Functions

Transform values using custom functions:

Configuration
Result

Object Mapping

Create new objects by mapping properties:

Configuration
Result

Array Processing with Loop

Process arrays and transform each item:

Configuration
Result

Validation

Validate values and return undefined if validation fails:

Configuration
Result

Only return values when required consent is granted:

Configuration
Result

Destination Integration

Mapping configurations are typically defined in destination configs:

const destination = {
type: 'gtag',
init: () => ({
/* init config */
}),
push: (event, { data }) => {
// Use mapped data
gtag('event', event.event, data);
},
config: {
mapping: {
// Event mappings
product: {
view: {
name: 'view_item',
data: {
map: {
item_id: 'data.id',
item_name: 'data.name',
value: 'data.price',
currency: { value: 'USD' },
},
},
},
},
},
// Global data mapping
data: {
map: {
page_title: 'context.title',
page_location: 'context.url',
},
},
},
};

Best Practices

  1. Use specific mappings over wildcards when possible for better performance
  2. Leverage conditions to handle different event scenarios
  3. Validate critical data before sending to destinations
  4. Respect consent requirements by using consent-based mappings
  5. Keep transformations simple - complex logic should be in custom functions
  6. Test mappings thoroughly with different event scenarios
💡 Need Professional Support?
Need professional support with your walkerOS implementation? Check out our services.