Trait - User Property
Trait user properties selects the last observed trait
value of an identify
event. It is the most basic and commonly used user property type. They can be used to render individual values, or to render arrays and objects.
Example Use Case - Plan
As an example, imagine that you’re running a SAAS business, where users can be subscribed to one of several plans. You can create a plan
trait.
This property would then be available to render in a template.
Example Use Case - Recommendations
Let’s say you’re running an online store, and you want to show recommendations to a user. You have a set of recommendations for each user that you’ve pre-calculated. You can create a recommendations
trait, and use it to render a list of products.
This is a demonstration of how Trait
user properties can be used to render arrays and objects in addition to strings.
Path Syntax
Paths use JSON path syntax as documented in the JSONPath specification, with one deviation.
If the path starts with a $
, it is treated as a JSONPath expression. Otherwise, it is automatically prefixed with $.
. So, for example, the path $.store.book[0].title
and store.book[0].title
are equivalent.
Prefixing the path with $
is optional, but it is useful when your path contains whitespace or other characters that are not valid in JSONPath expressions. For example, the path $['property name with spaces']
is valid, but ['property name with spaces']
is not.