Skip to main content
Version: 2.0.0

Targeting Features

Targeting lets you control which users see which variants based on user attributes. You can target by any attribute you pass from your application — user role, subscription tier, region, signup date, and more.

How Targeting Works

When evaluating a feature, you pass a user object containing a unique ID and any attributes. Featureflow evaluates rules from top to bottom and returns the variant for the first matching rule.

The Failover Rule

Every feature has a failover rule — the catch-all "else" rule at the bottom. If no other rules match, users receive the variant defined in this rule.

Failover Rule

Creating Rules

  1. Click Add Rule — a new rule panel appears above the failover rule
  2. Select a target attribute (e.g., tier, user_role, country)
  3. Choose a comparator — options vary by data type (text, number, or date)
  4. Enter the value(s) to match against
  5. Select the variant or split to return when the rule matches
  6. Click Save Targeting
Create targeting rule

Comparators

The comparators offered depend on the attribute's data type. Values are compared strictly by type — a text comparator never matches a number, and a number comparator never matches text, so make sure the attribute your application sends has the type you expect.

Text

ComparatorMatches when the attribute…
equalsis exactly this value
containscontains this value anywhere
startsWithbegins with this value
endsWithends with this value
matchesmatches a regular expression — see below
inequals any of the listed values
notInequals none of the listed values

Number

ComparatorMatches when the attribute…
greaterThan / greaterThanOrEqualis greater than (or equal to) this number
lessThan / lessThanOrEqualis less than (or equal to) this number

Date

ComparatorMatches when the attribute…
before / afteris before / after this date-time

Dates are compared as ISO-8601 date-times, with or without a timezone offset. A date-only value such as 2026-07-03 means midnight UTC, so a rule scheduled this way takes effect at the same instant for every user worldwide.

in and notIn accept a list of values; every other comparator takes a single value.

Matching with regular expressions

The matches comparator tests the attribute against a regular expression:

  • It matches anywhere in the value. The pattern admin matches superadmin. To match the whole value, anchor the pattern with ^ and $.
  • Matching is case-sensitive and there are no flags. To match regardless of case, spell out both cases: [Bb]eta.

Some useful patterns:

  • @example\.com$ — email addresses on a domain
  • ^(alpha|beta)$ — exactly one of several values
  • ^\d+$ — digits only
  • ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$ — a UUID

Portable patterns

Targeting rules are evaluated inside your application by the Featureflow SDK, using your platform's own regular-expression engine. Those engines don't all support the same syntax, so Featureflow accepts the portable subset that behaves identically on every platform — guaranteeing a rule gives the same answer whether it runs in a browser, a JVM, a Go service, or a mobile app.

Supported: literal text, ., anchors (^, $, \b, \B), character classes like [a-z0-9] and [^…], the class shorthands \d \D \s \S \w \W, escapes \n \r \t \f and \xHH, groups (…) and (?:…), alternation with |, and the quantifiers *, +, ? and {n}, {n,}, {n,m} (up to 1000 repeats, with lazy ? variants).

Not supported: lookahead and lookbehind, backreferences, named groups, inline flags such as (?i), and escapes like \u, \p or \v that platforms interpret differently. Literal braces and brackets must be escaped: \{, \[. If a pattern uses unsupported syntax, the rule editor tells you as you type — and explains the portable way to write the same thing.

One subtlety worth knowing: on a few platforms \d, \w and \s can also match non-ASCII digits and letters. If you need strictly ASCII matching, use explicit classes such as [0-9] or [A-Za-z0-9_].

Multiple Conditions

Use the + and - buttons to add multiple conditions to a rule. All conditions within a rule are evaluated with AND logic — all must match for the variant to be returned.

Rule Order

Rules are evaluated top to bottom. The first matching rule wins. Drag rules to reorder them.

Multiple Rules

Reusing Conditions with Audiences

If you find yourself repeating the same conditions across features, save them as a named audience and select it in the rule's Match users by dropdown instead of defining the conditions inline.

Passing User Attributes

To use targeting, pass user attributes when evaluating features in your application:

JavaScript
var user = {
id: 'user-123',
attributes: {
name: 'john',
tier: 'gold',
user_role: 'pvt_tester'
}
}
Java
FeatureFlowUser user = new FeatureflowUser(userId)
.withAttribute("user_role", "pvt_tester")
.withAttribute("tier", "gold")
.withAttribute("tenure_years", 10)
.withAttribute("signup_date", new DateTime());

The attributes you pass become available as targeting options in the dashboard.