Rule Builder
The visual rule builder lets you define segment conditions without writing any code or JSON.
Opening the Rule Builder#
Navigate to Segments in the sidebar, then click + New Segment. Enter a name and (optionally) a description, then click Create. You land on the segment detail page with the rule builder open.
For an existing segment, open it from the Segments list and click the Edit Rules tab (or the pencil icon).
Adding Conditions#
Click + Add Condition to append a new row to the conditions list. A dropdown lets you choose the condition type. Based on your selection, different form fields appear:
- event_count — Event Type, Operator (gte/lte/eq/…), Value, optional Window (days)
- recency — Event Type, Operator (gt/lt/eq), Window Days
- monetary — Event Type, Property (e.g.,
total), Metric (sum/avg/max), Operator, Value - event_property — Event Type, Property, Operator, Value
- user_property — Property, Operator, Value
- event_sequence — ordered list of event types, Window Days, Strict toggle
- segment_membership — Segment picker, Operator (in/not_in)
AND / OR Logic Toggle#
The logic toggle at the top of the conditions list switches between AND (user must satisfy every condition) and OR (user must satisfy at least one). Click the badge to toggle.
Real-Time Preview#
As you build conditions, SegOps shows a live preview of the estimated matched user count using a sample query against recent events. This is not a full compute — it uses a time-boxed sample — so the number may differ slightly from a full membership computation.
You can also click Preview to run a manual preview that returns up to 10 sample matching user IDs and the raw analytics SQL the rule compiles to.
Saving and Computing#
Click Save Definition to persist the current conditions as a new version snapshot. This does not trigger a compute. To update the membership list, click Recompute. The page shows a spinner and polls for completion.
Version History#
The History panel (right side of the detail page) shows every saved definition snapshot with timestamp and author. Click any version to view its conditions. You can restore a previous version by clicking Restore this version.
Explain Mode#
Use the Explain feature to debug why a specific user is or is not in a segment. Enter a user ID in the Explain panel, then click Explain. Each condition row shows:
- The condition label (e.g., “sum(order_placed.total) ≥ 500”)
- The user's actual value (e.g., 623.45)
- The threshold (e.g., 500)
- A pass/fail indicator
This is powered by the GET /api/explorer/users/<user_id>/segments/<segment_id>/explain/ endpoint.