Segments
On-device segment evaluation in the SDK
Segments
The SDK evaluates segment membership on-device using definitions synced from the server. This powers real-time campaign triggering without network round-trips.
How segments work
- You define segments in the Nuxie dashboard using the segment builder -- combining user properties, event history, feature access, and other segment memberships into rules.
- The server compiles those rules into a compact format and delivers them to the SDK as part of the profile payload.
- The SDK evaluates each segment's rules locally, using data already on the device.
- When a user enters or exits a segment, the SDK notifies the campaign engine, which can start or stop a campaign journey.
Evaluation cycle
The SDK evaluates segment membership periodically:
- Evaluation runs every 60 seconds by default.
- An immediate evaluation also runs whenever the profile is refreshed (on launch, after
identify(), or afterrefreshProfile()).
Each evaluation cycle checks every segment definition against the current device state and produces enter/exit/remain results.
What evaluation uses
Segment rules can reference four types of data, all resolved locally:
Because evaluation is local, results reflect the state of data currently on the device. The next profile refresh reconciles any drift with the server.
Persistence
Segment memberships are persisted on disk per user. When the app restarts, the SDK loads cached memberships before the first evaluation cycle runs. This means:
- Campaigns that depend on segment membership can react immediately on cold start.
- The first periodic evaluation cycle updates memberships if anything has changed since the last session.
When the user logs out (reset()), segment memberships for the previous user are cleared.
Segment-driven campaigns
Segments are a primary trigger type for campaigns. In the dashboard, you can configure a campaign to start when a user enters a segment and optionally exit when they leave.
The SDK handles this automatically: when the evaluation cycle detects a segment change, it notifies the campaign engine, which checks all segment-triggered campaigns and starts or stops journeys as needed.
Next steps
- Campaigns -- configure segment-triggered campaigns in the dashboard
- Segment Builder -- learn how to define segment rules
- Tracking Events -- events feed segment evaluation