Skip to content

FlagDiligence docs

Targeting and segments

Serve the right value to the right users.

Targeting rules

Open a flag, choose the environment, and select Add rule. A rule has a name, one or more conditions, and the variation to serve. Rules run in priority order, lowest number first, and the first match wins.

Priority 1  email ENDS_WITH "@yourcompany.com"   -> new feature (100%)
Priority 2  custom.betaOptIn EQUALS "true"       -> new feature (100%)
Default     everyone else                          -> new feature (25% rollout)

Operators

OperatorMatchesExample
EQUALS / NOT_EQUALSAn exact value, or anything elseplan NOT_EQUALS "free"
CONTAINS / NOT_CONTAINSA piece of textemail CONTAINS "@company.com"
STARTS_WITH / ENDS_WITHThe start or end of textemail ENDS_WITH "@company.com"
IN / NOT_INA list of valuescountry IN ["US","CA","UK"]
GREATER_THAN / LESS_THANA numberaccountDays LESS_THAN 30

Attributes you can target

You can target on key, email, name and any custom attribute you pass in the user object:

const user = {
  key: 'user-123',              // required, stable and unique
  email: 'user@example.com',
  name: 'Asha Rao',
  custom: {
    plan: 'enterprise',
    country: 'IN',
    deviceType: 'mobile',
    betaOptIn: true,
  },
};

Browser, device, operating system, language, country and screen size are not collected for you. Detect them in your app and pass them as custom attributes, then target on them. Create the user object once when your app starts, not on every render.

Segments

A segment is a reusable group defined by rules, such as Beta testers or Enterprise customers. Build it once under Segments, then pick Use segment when you add a rule to any flag.

SegmentRule
Beta testerscustom.betaOptIn EQUALS "true"
Mobile userscustom.deviceType IN ["mobile","tablet"]
Paid userscustom.plan IN ["starter","pro","enterprise"]
North Americacustom.country IN ["US","CA"]
English speakerscustom.language STARTS_WITH "en"

Combining rules with a rollout

A common pattern is internal users first at 100%, opt-in beta users next, and then a percentage of everyone else. Raise the percentage in steps as you watch your metrics.

← Core conceptsNode.js SDK →

Need help with FlagDiligence?

Open the app, or tell us what you are trying to do.