Computed fields
Definition
A computed field is a dynamic field defined in the schema, linked to a script that is triggered for each new user activity or profile update and performs a computation of a function's result on a regular basis. It is used when the desired outcome cannot be achieved with existing directives or to simplify an OTQL query by replacing multiple directives with a single field.
Those fields can be used in segment definition to improve analysis and sharing, or in the Experiment feature to enhance control groups creation.
Examples
Those examples are handled by computed fields:
Retrieve the most recent event (e.g. last visit, last transaction, etc.)
Get the total amount for a specific type of event (e.g. sum of transactions in the last 30 days, total expenditure on a particular category of product, etc.).
Weighted sum (Affinity total, etc.)
Compare multiple channels (e.g. to find the best channel for transactions).
This example should be handled by a standard directive:
Get all users with at least a specific amount for one category
This example can't be handled by a computed field:
Identify the top X% of a specific user group (e.g. the top 10% of buyers).
Usage Example
Once live, a computed field behaves like a regular field, making it transparent to the user. Here's how you can use it in practice:
Use Case: Identify Users Who Have Spent More Than 100€ on IT Products in the Last 3 Months
With Standard Directives:
This query uses standard directives to sum the basket amounts for IT products over the last 3 months.
With a Computed Field:
In this version, the computed field IT_amount_3months
is used directly in the query. The field is calculated on a regular basis, meaning no computation is performed during query execution. This results gives faster query response times, as the value is precomputed and readily available.
Last updated
Was this helpful?