Search docs
Find a page, section or endpoint

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.

Big spenders, active recently, not refund-heavy
{
  "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#

opvalueTrue whenWorks on
eq neq gt gte lt ltenumberThe comparison holds (exact decimals, safe for money)Number metrics
between[lo, hi]lo ≤ metric ≤ hi, inclusive at both endsNumber metrics
exists / missingnoneThe customer has / doesn't have this metricAll metrics
within_dayswhole daysHappened in the last N daysTime metrics, text and list metrics
beyond_dayswhole daysLast happened more than N days agoTime metrics, text and list metrics

Missing metrics#

A condition on a metric the customer doesn't have is false, except missing, which is true.

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#

StageWhat happens
Writing a ruleUse preview: it validates the rule and counts matches without saving anything.
CreationEvery existing customer is evaluated once (a "backfill"), so the segment is accurate from the start.
After creationRules are fixed. To change one, create a new segment id. Only status can change.

Status values: draft active paused archived

Next#