Build Audience Rules
Audience rules define the exact criteria customer records must satisfy to qualify for an audience segment. DriveMetaData provides a visual, drag-and-drop rule builder that translates complex nested Boolean logic into high-performance ClickHouse filter queries.
1. Module Overview & Business Outcomes
The Visual Rule Builder allows operators to combine customer profile attributes, behavioral events, and predictive indicators using:
- Root Match Modes (
ALLvs.ANY): Define whether users must meet every top-level criterion or at least one. - Nested Rule Groups: Structure multi-condition clusters with independent evaluation logic.
- Exclusion Logic (
NOT): Suppress recent converters, churned accounts, or ineligible cohorts. - Granular Time Windows: Restrict behavioral actions to exact historical or rolling timeframes.
2. Prerequisites, Entitlements & RBAC
- Role: Requires
EditororAdminpermissions to add, edit, duplicate, or delete audience conditions. - Catalog Access: Available catalog fields must be loaded from
analytics-query-engine. - Lookback Limit: Time windows must not exceed the system maximum of 365 days.
3. Core Rule Architecture
Every audience rule set is structured as a hierarchical tree:
Root Match Mode
At the very top of the canvas, select the root evaluation mode:
- ALL (AND): Users must qualify under every top-level condition and group. Recommended for targeted conversion campaigns.
- ANY (OR): Users qualify if they meet any single condition or group. Recommended for broad awareness or multi-channel acquisition pools.
4. Canonical Step-by-Step Walkthrough
Step 1: Add Conditions
- Click + Add condition within the target group.
- Select the Source Category (e.g.,
Events). - Select the Attribute (e.g.,
Event Type). - Select the Operator (e.g.,
equals). - Enter or select the Value (e.g.,
add_to_cart).
Step 2: Configure Lookback Time Windows
For behavioral events, commerce actions, or touchpoints, specify the evaluation window:
- Preset Durations: Select
in last 7 days,in last 30 days,in last 90 days, orin last 365 days. - Rolling Ranges: Configure dynamic spans like
from 7 days ago to nowornow to 2 weeks from nowfor forward-looking event triggers.
Step 3: Add Nested Groups
When requirements require mixed logic (e.g., (In India AND purchased) AND (Came from Google OR Facebook)):
- Click + Add group.
- Set the group match mode to Match all (
ALL) or Match any (ANY). - Add the individual conditions inside the nested container.
Step 4: Add Exclusion Logic (NOT)
To remove ineligible customers:
- Click + Add group and toggle the container mode to Exclude matches.
- Add the conditions that define disqualified users (e.g.,
Event Type equals purchase in last 30 days). - Any user matching these criteria is subtracted from the final audience population.
Step 5: Duplicate or Reorder Conditions
- Click the Copy icon on any condition card to duplicate its settings for fast variant creation.
- Click the Trash icon to delete obsolete rules.
- Use Clear all to wipe the canvas and restart from scratch.
5. Supported Operators by Data Type
| Data Type | Supported Operators | Usage Example |
|---|---|---|
| String | equals, notEquals, in, notIn, isSet, isNotSet | Customer.country in ['India', 'UAE'] |
| Number & Money | equals, notEquals, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, between, isSet, isNotSet | Orders.purchaseCount greaterThanOrEqual 2 |
| Date & Time | equals, before, after, between, isSet, isNotSet | Customer.createdAt after '2026-01-01' |
| Boolean | equals, notEquals | Customer.isSubscribed equals true |
6. Canonical Business Recipes
Recipe 1: High-Intent Cart Abandoners (30 Days)
- Goal: Recover potential buyers who added items to their shopping cart but failed to complete checkout.
- Root Match Mode:
ALL (AND) - Condition 1 (Inclusion):
Events.eventTypeequalsadd_to_cartwith time windowin last 30 days. - Group 2 (Exclusion / NOT):
Events.eventTypeequalspurchasewith time windowin last 30 days.
Recipe 2: Churn-Risk VIP Customers
- Goal: Retarget high-value accounts showing declining activity.
- Root Match Mode:
ALL (AND) - Condition 1:
Orders.totalRevenuegreater than500. - Condition 2:
Prediction.churnRiskequalsHigh. - Group 3 (Exclusion / NOT):
Events.eventTypeequalssession_startwith time windowin last 14 days.
7. Troubleshooting & Error Playbook
| Symptom | Probable Root Cause | Actionable Resolution |
|---|---|---|
Validation error: missing_filters | An empty group card exists on the canvas without any configured conditions. | Add at least one condition to the group or delete the empty group card. |
Validation error: invalid_date_range | A condition time window exceeds the maximum allowed 365 days. | Reduce the time window to 365 days or fewer. |
| Zero matching users returned | Conflicting inclusion conditions in an ALL (AND) group (e.g., Country = India AND Country = UAE). | Change the group mode to ANY (OR) or check that conditions do not contradict one another. |
| JSON does not match visual canvas | Changes were made in the raw JSON editor without submitting or validating. | Switch back to Visual Builder and use the interactive controls to update rules safely. |
8. Downstream Handoff & Next Steps
- Validate, Estimate, and Preview: Test your rules against the query engine and inspect sample user records.
- Save, Export, and AI Generation: Generate rules using natural language prompts or save the completed audience.
- Audience Query Payload Schema: Review the JSON filter schema.