Concepts
Sources
Sources are where we pull information from when defining our conditions and transforms in various different entities.
Where can we use sources?#
In conditions and transforms when defining:
What kind of sources are available?#
Depending on where we are using them, they can be:
payload
: the attribute or event's payload that was set or trackedeventName
: the name of the event that was trackedattributeName
: the name of the attribute that was setattributes
: all the accumulated attributes set using the SDKstate
: when dealing with effect's internal state
Condition#
It would be easiest to understand how sources work if we see them in action.
Below, we are defining a condition in a destination to filter events based on the event name:
conditions: - source: eventName operator: equals value: pageView
Notice the source
property, which is suggesting to pull in the value from the event's name before applying the equals
operator in the condition.
We could have also applied a different source, like only filtering for events where the userId
attribute is of a certain value:
conditions: - source: attributes.userId operator: equals value: user-123
Sources can have dot-separated paths to access nested properties.
The same source for getting userId
attribute's value could have been also written as:
conditions: - attribute: userId operator: equals value: user-123
Usage examples#
source#
When using sources with direct paths:
# event's namesource: eventName# individual event or attribute's payloadsource: payload# attribute's namesource: attributeName# all the accumulated attributessource: attributes# dot-separated path to a propertysource: attributes.device.id
Below you will find several other shorthands for sources:
attribute#
When picking an individual attribute:
attribute: attributeName
The path can be nested as well with dot-separated path:
attribute: user.country
payload#
When picking an individual event or attribute's payload:
payload: propertyName
The path can be nested as well with dot-separated path:
payload: propertyName.nestedPropertyName
lookup#
Lookups help read information on demand via installed modules in your application.
An example could be reading from the browser's localStorage via module-localstorage:
lookup: localstorage.<keyHere>
Learn more in lookups page.