Flipswitch
Guides

Targeting & Segments

Advanced targeting rules and percentage rollouts

Targeting & Segments

This guide covers advanced targeting strategies for controlling who sees your features.

Targeting Rules

Targeting rules determine which variant a user receives based on their evaluation context.

Rule Structure

Each rule consists of:

  1. Conditions - Criteria that must match
  2. Variant - The value to return if conditions match
  3. Priority - Order of evaluation (first match wins)

Creating Rules

  1. Navigate to your flag in the dashboard
  2. Select the environment (dev, staging, prod)
  3. Click Add Rule
  4. Configure conditions and select a variant

Operators

String Operators

OperatorDescriptionExample
EQUALSExact matchemail EQUALS "admin@company.com"
NOT_EQUALSNot equalplan NOT_EQUALS "free"
CONTAINSSubstring matchemail CONTAINS "test"
STARTS_WITHPrefix matchemail STARTS_WITH "admin"
ENDS_WITHSuffix matchemail ENDS_WITH "@company.com"
MATCHESRegex matchemail MATCHES ".*@(alpha|beta)\\.com"

List Operators

OperatorDescriptionExample
INValue in listcountry IN ["SE", "NO", "DK"]
NOT_INValue not in listplan NOT_IN ["free", "trial"]

Numeric Operators

OperatorDescriptionExample
EQUALSEqual toage EQUALS 25
GREATER_THANGreater thanage GREATER_THAN 18
LESS_THANLess thanversion LESS_THAN 2.0

Segments

Segments are reusable groups of users that can be referenced in targeting rules.

Why Use Segments?

Instead of repeating complex conditions across multiple flags:

Rule: email ENDS_WITH "@company.com" OR plan EQUALS "enterprise"

Create a segment and reference it:

Rule: user IN SEGMENT "beta-users"

Creating Segments

  1. Navigate to Segments in your project
  2. Click Create Segment
  3. Define the conditions
  4. Save with a meaningful name

Segment Examples

Internal Users:

email ENDS_WITH "@yourcompany.com"

Beta Testers:

email IN ["beta1@example.com", "beta2@example.com"]
OR
tag EQUALS "beta-tester"

Enterprise Customers:

plan EQUALS "enterprise"
OR
account_type IN ["enterprise", "enterprise-plus"]

Geographic Region:

country IN ["SE", "NO", "DK", "FI"]

Percentage Rollouts

Gradually release features to a percentage of users.

How It Works

  1. User's targetingKey is hashed
  2. Hash is mapped to a bucket (0-99)
  3. Bucket determines which variant they receive
0-9    (10%) -> variant-a
10-29  (20%) -> variant-b
30-99  (70%) -> control

Properties

  • Deterministic - Same user always gets the same variant
  • Consistent - Increasing percentage doesn't reassign existing users
  • Statistically valid - Even distribution for A/B tests

Configuring Rollouts

  1. Navigate to your flag's environment settings
  2. Click Add Percentage Rollout
  3. Set percentages for each variant (must total 100%)

Always ensure percentages sum to 100%. The last variant receives any remainder.

Combining with Targeting

Rollouts can be combined with targeting rules:

IF segment IS "beta-users"
  THEN 100% -> new-feature
ELSE IF segment IS "enterprise"
  THEN 50% -> new-feature, 50% -> old-feature
ELSE
  THEN 100% -> old-feature

Best Practices

1. Start Small

Begin with a small percentage (1-5%) and gradually increase:

Week 1: 1% rollout
Week 2: 10% rollout
Week 3: 25% rollout
Week 4: 50% rollout
Week 5: 100% rollout

2. Use Kill Switches

Always have a way to instantly disable a feature:

  • Toggle the flag off in the dashboard
  • SSE pushes the change to all clients immediately

3. Target Internal Users First

Create an "internal" segment and test new features there before broader rollout:

IF segment IS "internal-users"
  THEN new-feature
ELSE
  THEN old-feature

4. Monitor Metrics

Track key metrics during rollout:

  • Error rates
  • Performance
  • User engagement
  • Business KPIs

5. Document Your Rules

Use meaningful segment and variant names:

  • premium-checkout-v2 instead of variant-a
  • enterprise-customers instead of segment-1