This product is not supported for your selected Datadog site. ().
Overview
Targeting rules define which variant to serve to which subjects. Each rule can include a filter, one or more variants, and an optional percentage rollout. Rules are evaluated in order until a match is found.
Targeting rule types
Datadog supports different targeting rule types depending on your rollout strategy:
Type
Description
Feature gate
Roll out to a percentage of subjects matching your filter (randomized or not), immediately or at a scheduled start time
Progressive rollout
Randomized rollout over a schedule with multiple steps, started manually or at a scheduled start time
Experiment
Randomized allocation associated with an experiment
Configure targeting rules
To configure targeting rules for a flag:
Navigate to Feature Flags and select your flag.
Select the environment whose rules you want to modify.
Click Add Targeting Rule (or click the targeting rule you want to modify).
For each targeting rule, configure the following:
Name your targeting rule: Give your targeting rule a name to describe the group it targets.
Define a filter (optional): If you do not define a filter, the rule matches all subjects in that environment. To reuse the same conditions across multiple flags, add a saved filter instead of redefining them on each flag.
Select variants: Choose which variants to serve to matching subjects. Click Split Traffic to randomize across multiple variants (see Traffic Splitting and Randomization).
Schedule a start time (optional): Activate the rule automatically at a future date and time instead of immediately (see Scheduled Rollouts).
After configuring your targeting rules, click Save, then enable the flag in the environment so SDKs can evaluate targeting rules. You can also use the evaluation tester to simulate how the rule evaluates for a given targeting key and attributes, without affecting production data.
SDKs do not evaluate targeting rules when the flag is disabled or overridden in an environment. If the flag is overridden with a fixed variant, the SDK returns that variant. If the flag is disabled, the SDK returns the default value supplied by your application. For detailed evaluation behavior, see Flag Evaluation Results.
Filters and evaluation context
Filters use attributes from your SDK’s evaluation context. Define attributes when you set the evaluation context before evaluating flags. Attributes must be flat primitive values (strings, numbers, Booleans). Nested objects and arrays are not supported.
When you build a filter, the attribute field suggests attributes your organization has already defined or that your SDKs have sent recently. See Targeting Attributes to define reusable attributes with a data type, which also determines the operators available for that attribute.
Given an evaluation context with country, tier, user_role, and account_age_days attributes, you can build filters with different operators, such as equality, is one of, is not, or numeric comparisons:
countryis one ofUS, CA
tierequalspremium
user_roleis notguest
account_age_daysgreater than90
Rule hierarchy
Targeting rules are evaluated in order from top to bottom:
The SDK evaluates the first rule. If the subject matches the filter (or no filter is defined), the rule may serve a variant.
If the subject does not match, evaluation passes through to the next rule.
If no rule matches, the SDK serves the default variant for that environment.
Further reading
Additional helpful documentation, links, and articles: