Skip to main content

How targeting works

Every Zenstep flow has a targeting configuration — a set of rules that determine whether the flow should be shown to the current user on the current page. The targeting engine runs client-side in the browser (inside the Zenstep snippet) every time a page loads or the URL changes (SPA navigation). This means:
  • No server round-trip per evaluation — instant decision
  • Rules are evaluated against the current browser context (URL, user attributes, device, behaviour)
  • Targeting is evaluated against all published flows simultaneously

Anatomy of a targeting rule

Every rule has a type and evaluates to true or false. Rules are combined with and (all must match) or or (any must match) logic.
This targeting config shows the flow on any URL starting with /dashboard and only to users with plan = "free".

Rule types

TypeDescriptionPlan
url_pathMatch the current page URL pathAll plans
user_attributeMatch a user attribute from identify()All plans
deviceMatch device type (desktop / mobile / tablet)All plans
query_paramMatch a URL query parameterAll plans
alwaysShow to everyone, alwaysAll plans
behaviorMatch based on track() event historyGrow+
segmentMatch a saved reusable segmentGrow+
audience_membershipMatch a GA4 or Clarity-imported audienceScale+

Combining rules

Rules are combined at two levels:
  1. Top-level operator (and / or) — how the rules in the root array are combined
  2. Group rule — a nested rule that can contain its own rules and operator
This shows the flow on /pricing OR (on any dashboard page AND if the user is on the free plan).

Environments

You can restrict a flow to specific environments (staging vs production):
Zenstep detects the environment automatically based on hostname. You can override this by setting data-env on the snippet script tag:

Frequency controls

Targeting determines if a flow is shown. Frequency controls determine how often:
FrequencyBehaviour
onceShow at most once per user (checked via flow_completions table)
every_sessionShow on every new browser session
until_completedShow on every page load until the user completes the flow
Frequency is set per-flow in the flow editor, not in targeting rules.