Build audiences
Segments
Audiences defined as rules over metrics, re-evaluated automatically as customers change.
A segment is a rule over metrics that defines an audience. Each customer is either in or out, and BreezeIQ re-checks them whenever a metric the rule uses changes, so the audience stays current without any batch job.
Rules#
A rule is a JSON tree of all / any / not groups over metric conditions.
{
"all": [
{ "metric": "total_spend", "op": "gte", "value": 10000 },
{
"any": [
{ "metric": "order_count", "op": "gte", "value": 3 },
{ "metric": "last_order_at", "op": "within_days", "value": 30 }
]
},
{ "not": { "metric": "refund_count", "op": "gt", "value": 2 } }
]
}Operators#
op | value | True when | Works on |
|---|---|---|---|
eq neq gt gte lt lte | number | The comparison holds (exact decimals, safe for money) | Number metrics |
between | [lo, hi] | lo ≤ metric ≤ hi, inclusive at both ends | Number metrics |
exists / missing | none | The customer has / doesn't have this metric | All metrics |
within_days | whole days | Happened in the last N days | Time metrics, text and list metrics |
beyond_days | whole days | Last happened more than N days ago | Time metrics, text and list metrics |
Missing metrics#
A condition on a metric the customer doesn't have is false, except missing, which is true.
last_order_at beyond_days 90 does not include people who never ordered. To target them, say it explicitly: {"metric": "last_order_at", "op": "missing"}.
Time-based rules#
Rules using within_days or beyond_days change with time alone. BreezeIQ re-checks them periodically, so people age in and out without any new event. The API marks these segments "is_temporal": true.
Lifecycle#
| Stage | What happens |
|---|---|
| Writing a rule | Use preview: it validates the rule and counts matches without saving anything. |
| Creation | Every existing customer is evaluated once (a "backfill"), so the segment is accurate from the start. |
| After creation | Rules are fixed. To change one, create a new segment id. Only status can change. |
Status values: draft active paused archived