What Are Computed Traits?
Computed Traits are dynamically derived user attributes that are automatically calculated from existing profile data within Piano Audience. Rather than storing only raw, collected data points, Computed Traits let you define transformation logic that produces new, enriched attributes, unlocking deeper personalization, segmentation, and activation capabilities.
Common use cases include:
-
Combining fields: Merging a first name and last name into a single "full name" attribute.
-
Standardizing data: Converting strings to lowercase or uppercase for consistency.
-
Calculating metrics: Deriving average order value from total revenue and order count.
-
Conditional classification: Labeling users as "high value" or "at risk" based on behavioral thresholds.
-
Date normalization: Converting date fields to ISO 8601 format for cross-system compatibility.
How It Works
When you create a Computed Trait, you define logic that is evaluated automatically across three lifecycle stages:
|
Stage |
When It Runs |
|---|---|
|
Processing |
Whenever an existing user profile is updated |
|
Init |
When a new user profile is created |
|
Merge |
When two user profiles are combined into one |
The resulting computed value is stored as a new attribute on the user profile and can be used across Piano Audience for segmentation, activation, analytics, and personalization, just like any other profile attribute.
When Are Computed Traits Evaluated?
Computed Traits are evaluated in real time as soon as an update to any of the affected source attributes is recognized. This means that whenever a profile attribute referenced in your computed trait logic changes (for example, via an API call that updates the respective fields), the computed trait is automatically recalculated to reflect the new data.
There is no manual trigger or scheduled batch process required. As long as the source attributes are being updated through supported channels (such as the Audience API), your computed traits will stay current.
Two Modes of Creation
Piano Audience offers two modes for creating Computed Traits, designed to serve different user needs:
Basic Mode
A visual, no-code interface that lets you create computed traits by selecting functions and configuring arguments through dropdowns and input fields. Ideal for business users, marketers, and analysts who want to enrich profiles without writing code.
Best for: Common transformations like string concatenation, conditional logic, arithmetic operations, and data type conversions.
Advanced Mode
A JavaScript-based code editor that provides full programmatic control over computed trait logic. Ideal for developers and technical users who need complex, multi-step transformations or custom business logic.
Best for: Nested conditional logic, complex calculations, multi-field aggregations, and custom data transformations that go beyond the available UI functions.
→ Get started with Advanced Mode
Available Functions
Both modes leverage a shared set of built-in functions. The functions available to you depend on the data type selected for the computed trait:
|
Data Type |
Available Functions |
|---|---|
|
Boolean |
|
|
Integer / Float |
|
|
String / Text / Keyword |
|
|
Date / Time |
|
For detailed descriptions of each function, refer to the Basic Mode or Advanced Mode documentation.
Testing Your Computed Traits
Before deploying a Computed Trait to production, you can validate your logic using the built-in Dry Run and Preview & Test capabilities. These tools execute your trait logic against real sample profiles from your account, allowing you to verify correctness before saving.
→ Learn more about Testing (Dry Run & Preview)
Supported Data Types
Computed Traits support the following output data types:
|
Type |
Description |
Example |
|---|---|---|
|
INT |
Integers in the range -(2⁵³ − 1) to 2⁵³ − 1 |
|
|
FLOAT |
Double-precision 64-bit floating point numbers |
|
|
BOOLEAN |
Boolean values |
|
|
DATETIME |
ISO 8601 date-time with millisecond resolution |
|
|
STRING |
Arbitrary strings, optimized for wildcard searches |
|
|
KW |
Keywords (up to 255 chars), optimized for exact match |
|
|
TEXT |
Arbitrary strings, automatically tokenized for indexing |
|
Next Steps
|
Article |
Description |
|---|---|
|
Computed Traits: Basic Mode |
Step-by-step guide to creating CTs with the visual UI |
|
Computed Traits: Advanced Mode |
Guide to creating CTs with JavaScript |
|
Computed Traits: Testing (Dry Run & Preview) |
How to validate your CT logic before deployment |