When defining audiences, you sometimes need computed or calculated attributes rather than raw data. For example, you may want to create an audience based on Lifetime Value (LTV) though you don't have this column in your Users table. Creating it entails summing the price of all purchases made by a particular user.
Hightouch Traits enable users of any technical background to:
All SKUs a user added to their cart before abandoning it
Traits are defined within the Parent Model, but you can also create traits based on events to capture information about customer actions in a customer funnel.
See the section on how traits work for more information on how Hightouch calculates and joins traits to a parent model.
Add required configurations for the trait type. For SUM, for instance, you need to select which column to sum.
Click Save.
The trait is now part of the parent model, and you can use it when creating audiences. To include it as part of your synced data, you need to create trait enrichments.
Once you've created a trait, you can use it for filtering within your audiences. Traits are available under the property dropdown.
For example, if you created an LTV trait, you can use it to filter for "All users that have spent more than $100."
You can also add filters to apply before Hightouch calculates trait values. For example, you can restrict the LTV calculation to purchases where the Brand was Nike directly in the audience builder.
In addition to defining traits on parent models, you can also apply traits to events in the visual audience builder. Event traits automatically become trait enrichments, meaning you can view them in the preview and sync their values. One common use case for event traits is to capture information about abandoned carts.
To create a new event trait, click Add trait on an event condition in the audience builder.
Give the event trait a descriptive Name.
Select the aggregation you want to use, for example, Last.
Select the information you want to capture about the event. For example, you may want to capture the Product_ID, SKU, or Brand of the final product a user added to their cart before abandoning it.
Custom SQL traits provide a powerful escape hatch for custom aggregations that the default aggregations don't cover. To build a SQL trait, create a trait and follow these additional instructions:
Select SQL as the Aggregation type.
Enter a raw SQL aggregation. For example, to create a SUM trait with just SQL, you would enter SUM({{ column "price" }}).
Column references must use the following syntax {{column "<COLUMN_NAME>"}}. Column names are case-sensitive.
Enter a default value for when the SQL returns no rows.
Define the Property type of the SQL aggregation result.
See the section on how traits work for more information on how Hightouch calculates and joins custom SQL traits to a parent model.
JSON aggregations are a helpful way to aggregate the raw data in a related model. For example, imagine you want to get a list of all product IDs users have purchased. You can do this with the following SQL trait:
CASE statements are a useful way to create friendly options for aggregations. For example, imagine you want to bucket customers into low, medium, and high LTV. You can do this with the following SQL trait:
Under the hood, traits are computed in a subquery and JOINed to the parent model. For example, a SUM trait for "total purchase value" creates a
subquery as follows:
SELECT user_id, SUM(price)
FROM purchase_events
GROUPBY user_id
Hightouch applies additional constraints on the trait before generating the query. For example, the query for finding the "total purchase value over
the last seven days" is:
SELECT user_id, SUM(price)
FROM purchase_events
WHEREtimestamp> now() -interval'7 days'GROUPBY user_id
Custom SQL traits work by replacing SUM(price) in the preceding query with the custom SQL.
For example, to create a trait for the "average purchase price" using SQL, you would use AVG( {{column "price"}} ). This SQL generates this trait subquery:
SELECT user_id, AVG(price)
FROM purchase_events
GROUPBY user_id
Ready to get started?
Jump right in or a book a demo. Your first destination is always free.