Targeting rules
Decide who sees a flag or experiment, using attributes, segments and percentage rollouts.
A targeting rule decides which users get which variant. Rules are evaluated in order, and the first match wins. If none match, the user gets the default rule.
Attributes
Attributes come from the user object you pass to the SDK. Operators include equals, one of, contains, greater than, regex and semantic version comparisons.
{
"if": [
{ "attr": "country", "op": "in", "value": ["US", "CA"] },
{ "attr": "plan", "op": "eq", "value": "pro" }
],
"serve": { "percent": { "treatment": 50, "control": 50 } }
}Segments
A segment is a named set of conditions you can reuse across flags, such as internal staff or customers on an annual plan. Changing a segment updates every flag that uses it.
Percentage rollouts
Kerf hashes the user id with the flag key to pick a bucket from 0 to 9999. A user at bucket 3200 sees treatment as long as the treatment range includes it. Raising a rollout from 10% to 20% keeps every existing user in place and adds new ones.
Bucketing by something other than user
- Account id, so everyone in a company sees the same variant.
- Device id for logged out traffic.
- Session id for short experiments where users are anonymous.
Prerequisites
A flag can depend on another flag being on. Use this to put a risky feature behind a stable one without duplicating rules.
Testing a rule
Use the rule tester in the dashboard. Paste a user object and Kerf shows which rule matched and why.