Search documentation...

K

Traits

Traits are part of the Advanced Customer Studio, available as an add-on to Business Tier plans.

Overview

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:

You can use these computed fields, called traits, to supercharge personalization across marketing channels without having to rely on data teams.

Trait types

Trait TypeExample Usage
SumSum of price of all purchases a user has made in their lifetime
CountCount of songs listened to in the past two weeks
Most FrequentMost Frequent category of articles read
FirstFirst page a user visited
LastLast product a user viewed
Custom SQLAll 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.

Create a trait

  1. Go to the Parent Models page and select the parent model you want to add traits to.
  2. Go to the Traits tab and click Add trait.

Creating traits in the Hightouch UI

  1. Give the trait a descriptive Name, for example, "Lifetime Value."
  2. Select the related model from which you're aggregating column values.
  3. Select the trait type, for example, SUM.
  4. Add required configurations for the trait type. For SUM, for instance, you need to select which column to sum.
  5. Click Save.

Defining traits in the Hightouch UI

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.

Create audiences with traits

Once you've created a trait, you can use it for filtering within your audiences. Traits are available under the property dropdown.

Selecting a property in the Hightouch Audience builder

For example, if you created an LTV trait, you can use it to filter for "All users that have spent more than $100."

Using a trait to filter audiences

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.

Filtering traits in the Hightouch UI

Enrich audiences with traits

Adding trait enrichments makes trait values available for syncing to destinations. You add trait enrichments to specific audiences.

Adding a trait enrichment

  1. Go to the Trait enrichments tab of the audience you want to add enrichments to.
  2. Click Add trait.
  3. Enter a Name and select the Parent trait.
  4. [Optional] Add conditions to apply on top of the parent trait.

Defining a trait enrichment

Once created, these enrichment traits appear in the Audience preview and sync configuration like any other field.

Event traits

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.

  1. To create a new event trait, click Add trait on an event condition in the audience builder.

Adding an event trait in the Hightouch UI

  1. Give the event trait a descriptive Name.
  2. Select the aggregation you want to use, for example, Last.
  3. 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.

Defining an event trait in the Hightouch UI

Custom SQL traits

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:

  1. Select SQL as the Aggregation type.
  2. 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.
  1. Enter a default value for when the SQL returns no rows.
  2. 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

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:

ARRAY_AGG(DISTINCT {{column "product_id"}})

CASE statements

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:

CASE
  WHEN SUM( {{column "price"}} ) > 100 THEN 'high'
  WHEN SUM( {{column "price"}} ) > 50 THEN 'medium'
  ELSE 'low'
END

How do traits work?

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
GROUP BY user_id

Added conditions

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
WHERE timestamp > now() - interval '7 days'
GROUP BY user_id

Custom SQL traits

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
GROUP BY user_id

Ready to get started?

Jump right in or a book a demo. Your first destination is always free.

Book a demoSign upBook a demo

Need help?

Our team is relentlessly focused on your success. Don't hesitate to reach out!

Feature requests?

We'd love to hear your suggestions for integrations and other features.

Last updated: Jan 18, 2023

On this page

OverviewTrait typesCreate a traitCreate audiences with traitsEnrich audiences with traitsEvent traitsCustom SQL traitsJSON aggregationsCASE statementsHow do traits work?Added conditionsCustom SQL traits

Was this page helpful?