Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/unify/Traits/computed-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Computed Traits allow you to quickly create user or account-level calculations t

{% include content/trait-types.md %}

## Types of Computed Traits
## Types of computed traits

Segment currently supports the following types of computed traits:
- [Types of Computed Traits](#types-of-computed-traits)
Expand All @@ -41,7 +41,7 @@ Segment currently supports the following types of computed traits:
> warning "Event Properties per Computed Trait limit"
> Segment limits the number of Event Properties on each Computed trait to 10,000. If your Computed Trait exceeds this limit, Segment will not persist any new Event Properties and will drop new trait keys and corresponding values.

### Event Counter
### Event counter

An Event Counter trait stores a count of an **event** over a period of time. For example, you can create a trait called `number_logins_90_days` based on a `User Logged In` event. You can also use event properties to only specific types of events.

Expand Down Expand Up @@ -69,9 +69,9 @@ Account-level use cases

![An aggregation trait run over the course of 90 days](../images/1525835663131.png)

### Most Frequent
### Most frequent

A most frequent user-level computed trait will return the **most common value** for an **event property**. This is helpful to create traits like `preferred_product_viewed` or `most_commonly_viewed_category` that tell you what a user's preferred product, or content category might be. Note that the most frequent computed trait requires the event property to have been tracked at least twice. In the case of a tie, Segment returns the first alphabetical value. For account-level computed traits, you can also return the most frequent **user trait**. This is helpful when you want to determine which user has performed an event the most frequently. For example, you might to return the email of the user in an account most actively viewing your app.
A most frequent user-level computed trait will return the **most common value** for an **event property**. This is helpful to create traits like `preferred_product_viewed` or `most_commonly_viewed_category` that tell you what a user's preferred product, or content category might be. Note that the most frequent computed trait requires the event property to have been tracked at least twice. In the case of a tie, Segment returns the first alphabetical value. For account-level computed traits, you can also return the most frequent **user trait**. This is helpful when you want to determine which user has performed an event the most frequently. For example, you might to return the email of the user in an account most actively viewing your app.

User-level examples:
- Favorite Blog Post
Expand Down Expand Up @@ -113,7 +113,7 @@ Account-level examples:
![The last event-seen trait builder](../images/1525836818177.png)


### Unique List
### Unique list

Unique list computed traits will output a **list of unique values** in alphabetical order for an **event property**. This is helpful to understand the different types of products or content that a customer or users in an account have interacted with or purchased. Customers are creating traits like `unique_product_categories_viewed` and sending them to email marketing tools and accessing them through the Profiles API for in-app personalization.

Expand All @@ -125,7 +125,7 @@ Example use cases:
![The unique list trait builder](../images/1525837083070.png)


### Unique List Count
### Unique list count

Unique list count computed traits will output a **count of the unique list of values** for an **event property**. Customers are creating traits like `unique_product_categories_viewed_count` to understand the variety of products that a customer is viewing. At the account-level, customers are creating traits like `unique_visitors_count` to calculate the number of unique visitors by ip address.

Expand All @@ -144,7 +144,7 @@ Account-level examples:

All computed trait types support a common "Add Conditions" section. Conditions defined here restrict the messages considered when calculating the final value of the computed trait by looking at a property of the events. For example, you could limits events to only those where "price" is greater than 30.00 or where "page.url" contains "pricing".

The following operators are available.
The following operators are available:
- equals
- not equals
- less than
Expand All @@ -162,15 +162,15 @@ The following operators are available.
- equals one of
- contains one of

## Connecting your Computed Trait to a Destination
## Connecting your computed trait to a destination

Segment sends user-level computed Traits to destinations using the [Identify call](/docs/connections/spec/identify/) for user traits, or using the [Track call](/docs/connections/spec/track/) for event properties. Segment includes the trait value and property in the Identify and Track calls.

For example, the name of a computed trait is added to the user profile as a trait, and the trait's value is set to the value of the computed trait. Segment sends an Identify or Track call when the trait is computed, depending on the destination configuration. If a computed trait counts the number of times a user visits your pricing page, and the user visits your pricing page five times, Segment sends an Identify call with the property `pricing_page_visits: 5`.

Learn more about [Computed trait generated events here](/docs/engage/using-engage-data/#computed-trait-generated-events). The trait name corresponds to the snake cased name that you see in the trait settings, for example `most_viewed_page_category`. See the [list of Engage-compatible destinations](/docs/engage/using-engage-data/#compatible-engage-destinations)
See [Computed trait generated events](/docs/engage/using-engage-data/#computed-trait-generated-events) to learn more. The trait name corresponds to the _snake_cased_ name that you see in the trait settings, for example `most_viewed_page_category`. See the [list of Engage-compatible destinations](/docs/engage/using-engage-data/#compatible-engage-destinations).

For account-level computed traits, you have the option to send either a [Group](/docs/connections/spec/group/) call and/or [Identify](/docs/connections/spec/identify/) call. Group calls will send one event per account, whereas Identify calls will send an Identify call for each user in the account. This means that even if a user hasn't performed an event, Segment will still set the account-level computed trait on that user. Because most marketing tools are still based at the user level, it is often important to map this account-level trait onto each user within an account. See [Account-level Audiences](/docs/engage/audiences/account-audiences) for more information.
For account-level computed traits, you have the option to send either a [Group](/docs/connections/spec/group/) call and/or an [Identify](/docs/connections/spec/identify/) call. Group calls will send one event per account, whereas Identify calls will send an Identify call for each user in the account. This means that even if a user hasn't performed an event, Segment will still set the account-level computed trait on that user. As most marketing tools are still based at the user level, it is often important to map this account-level trait onto each user within an account. See [Account-level Audiences](/docs/engage/audiences/account-audiences) for more information.

> warning "Computed Traits can only be sent to Event destinations"
> When Engage sends a computed trait to an [Event destinations](/docs/engage/using-engage-data/#event-destinations), it uses an Identify call to send user traits and a Group call to send account-level computed traits.
Expand All @@ -183,7 +183,7 @@ After you create a computed trait, use the Overview page to view a compute progr
> info "Viewing compute progress"
> When you create a real-time computed trait, you'll see a progress bar, computed percentage, and status updates. For existing traits that you edit, Segment displays the compute status but not the progress bar or percentage.

## Editing Realtime Traits
## Editing realtime traits

Segment supports the editing of real-time Traits, which allows you to make nuanced changes to existing Traits in situations where cloning or building from scratch may not suit your use case.

Expand All @@ -200,7 +200,7 @@ Segment then processes your Trait edits. While the edit task runs, the trait rem
> warning ""
> It is not possible to edit a trait to convert it from real-time to batch, or vice-versa. If the computation type needs to be changed, you will need to recreate the trait with the appropriate conditions.

## Accessing your Computed Traits using the Profiles API
## Accessing your computed traits using the Profiles API

You can access your computed traits using the Profile API by querying the `/traits` endpoint. For example, you can query for the `emails_opened_last_30_days` with the following GET request:

Expand Down Expand Up @@ -231,13 +231,13 @@ By default, the response includes 20 traits. You can return up to 200 traits by

You can read the [full Profile API docs](/docs/unify/profile-api/) to learn more.

## Deleting Computed Traits
## Deleting computed traits

When computed traits are deleted, any user that had a value for that trait will now have a custom trait on the Unify profile.

## Downloading your Computed Trait as a CSV file
## Downloading your computed trait as a CSV file

You can download a copy of your trait by visiting the the computed trait overview page.
You can download a copy of your trait by visiting the computed trait overview page.
![Downloading a CSV file of computed traits in Segment](../images/trait_overview.png)
Computed Trait CSVs are generated on demand. Before you can download the CSV, you will need to generate it. There are three different options for formatting:
- **Unformatted:** Contains three columns. The first contains the user or account key, the second contains the trait value and the third is a JSON object containing the external IDs. Generating this CSV is by far the fastest of the three options. [Download example unformatted CSV](/docs/engage/files/trait_csv_format_a.csv)
Expand All @@ -247,7 +247,7 @@ Computed Trait CSVs are generated on demand. Before you can download the CSV, yo
<tr>
<td>![Handling large CSV file downloads](../images/large_trait_csv.png)</td>
<td width="45%">Generating a CSV can take a substantial amount of time for large traits (around 30 seconds for a formatted CSV with 1 million rows). For CSVs that are expected to take over 20 seconds, the Segment app displays an estimated generation time. After clicking Generate, it is recommended that you leave the modal and page open while the CSV is created.
(If the trait recalculates between when you click Generate and when you download the file, you might want to regenerate the file. The CSV is a snapshot from when you clicked Generate, and could be outdated.)</td>
(If the trait recalculates between when you click Generate and when you download the file, regenerate the file. The CSV is a snapshot from when you clicked Generate, and could be outdated.)</td>
</tr>
</table>

Expand Down
Loading