Skip to main content

Targeting Rules

Targeting rules define which users see your content. Rules are organized into a tree structure of groups and conditions, evaluated by the targeting engine at runtime.

Rule Tree Structure

A rule tree consists of rule groups and rule nodes:

  • Rule group -- a container with a logical operator (AND or OR) and one or more child rules or nested groups.
  • Rule node -- a leaf condition that compares a single user attribute against a value using a comparison operator.

Groups can be nested to express complex logic. An empty group evaluates to true.

AND Group
├── role eq "admin"
├── OR Group
│ ├── country in ["US", "CA"]
│ └── plan eq "enterprise"
└── loginCount gte 5

In this example, the user must be an admin and have logged in at least 5 times and be located in the US/CA or on an enterprise plan.

Comparison Operators

The targeting engine supports 15 comparison operators:

OperatorNameDescriptionAccepted Types
eqEqualsStrict equalityAny
neqNot equalsStrict inequalityAny
gtGreater thanField is greater than valueNumber
ltLess thanField is less than valueNumber
gteGreater than or equalField is greater than or equal to valueNumber
lteLess than or equalField is less than or equal to valueNumber
containsContainsString includes substring (case-insensitive), or array includes elementString, Array
not_containsDoes not containInverse of containsString, Array
inIn arrayField value exists in the provided arrayAny (rule value must be Array)
not_inNot in arrayField value does not exist in the provided arrayAny (rule value must be Array)
existsExistsField is not undefined or nullAny
not_existsDoes not existField is undefined or nullAny
regexRegex matchField matches a regular expressionString
starts_withStarts withField begins with the given prefix (case-sensitive)String
ends_withEnds withField ends with the given suffix (case-sensitive)String

Type Coercion Behavior

The evaluator uses strict typing with no implicit coercion:

  • Numeric operators (gt, lt, gte, lte) return false if either the field value or rule value is not a number.
  • String operators (contains, regex, starts_with, ends_with) return false if either operand is not a string.
  • contains and not_contains on strings use case-insensitive comparison. On arrays, string elements are compared case-insensitively while non-string elements use strict equality.

Client-Side Evaluation

The SDK evaluates targeting rules locally using the user context passed during initialization. The context object includes attributes such as userId, email, role, custom properties, and page URL. Rules are downloaded once on SDK initialization and re-evaluated when the user context changes.

Priority When Multiple Audiences Match

When a user matches more than one audience, content delivery follows these rules:

  1. Explicit priority -- audiences with a higher priority value take precedence.
  2. Specificity -- audiences with more matching rules are preferred when priorities are equal.
  3. First match -- if priority and specificity are identical, the first audience in creation order wins.

Only one variant of a given content item is shown to a user at any time.