Individual targeting
Overview
This topic explains how to control which individual contexts receive a variation of a feature flag, based on the context key.
Assign individual contexts to a variation
The flag’s Targeting tab allows you to assign individual contexts to a particular flag variation, based on the context key. You can target individual users or any custom context kind that exists in your project.
To individually target contexts:
-
In the flags dashboard, scroll or search to find the flag you want.
-
Click the flag’s name to open the flag’s Targeting tab.
-
Click the + button beneath the toggle section and select Target individuals.
- If the flag is off and the rules are hidden, click View targeting rules.
The "+" menu, with "Target individuals" called out. -
In the “Select or add a context” field, search for and select the context you want to target.
-
Alternatively, you can create a new context from the search menu. To do so:
- Enter the new context name.
- Click Create new.
- Select a context kind from the context kind menu.
-
Select a variation to Serve.
-
To add more contexts, click Add individual context.
-
Click Review and save.
Contexts that LaunchDarkly has evaluated within the last 30 days are indicated by a green icon. Click on an individual context name to view its context details.
You can search for individually targeted contexts using the search bar, or filter the list of individually targeted contexts by Context kind or Variation:
Only target small numbers of contexts individually
We recommend using individual targeting only for very small numbers of individual contexts. Individually targeting more than 10,000 contexts per environment may cause performance degradation, because the SDK takes longer to initialize when the targeting rules payload is large.
Instead, we recommend using targeting rules or segments to target large numbers of contexts. To learn how, read Custom targeting rules and Segment targeting.
If your application is already sending data back to LaunchDarkly, you can search for any context kind by name or key. These strings are case sensitive.
If you need to target a context that LaunchDarkly doesn’t know about, you can enter its key manually. These contexts display in yellow until they encounter a feature flag.
In the screenshot below, specific contexts are receiving the “True” variation of a flag:
You can also use the JSON editor
To learn how to create individual targeting rules using JSON, read Individual targeting.
You can also use the REST API: Individual context targets
Remove individual targets
You can remove individual targets from a flag:
-
Navigate to the flag’s Targeting tab.
-
Find the individual targeting rule and click Edit.
- If the flag is off and the rules are hidden, click View targeting rules.
-
Click the trash icon next to the context you want to remove:
An individually targeted user context with the trash icon called out. -
(Optional) If you need to undo the changes you just made, click the undo arrow icon to discard all changes:
A targeting rule's "undo arrow" button called out. - A “Discard unsaved changes” dialog appears. Click Discard changes to undo all the changes you have made, or Cancel to return to the details page.
-
Click Review and save.
Schedule removal dates for individual targeting
Scheduling removal dates is available to customers on select plans
Scheduling removal dates is only available to customers on select plans. To learn more, read about our pricing. To upgrade your plan, contact Sales.
You can schedule a removal date and time for each individual context that is targeted by a flag. By doing this, you can specify a future date and time after which the context will no longer be targeted for the specific flag. You can do this when you add a new individual target, or for existing individual targets.
This is useful if you want to give customers trial access to a feature, run a controlled beta test, or just keep your flags organized by not having too many flags working at once.
You can also schedule a context to be removed from a segment, rather than from flag targeting. To learn more, read Scheduling removal from segments.
To schedule a removal date for an individual target:
-
Navigate to the Flags list and select the flag for which you want to configure a removal date. The flag’s Targeting tab opens.
- If the flag is off and the rules are hidden, click View targeting rules.
-
Find the individual targeting rule and click Edit.
-
Click the calendar icon next to the context you want to schedule a removal date for:
An individual target with the calendar icon called out. -
Set a date and time for the context to be removed from the flag.
-
Click Save.
-
(Optional) If you need to undo the changes you just made, click the undo arrow icon to discard all changes.
-
Click Review and save.
The individual targets are now scheduled for removal on the date and time you specified.
Edit existing scheduled removal dates
Individual targets that already have a removal date scheduled appear with a red calendar icon.
To edit a scheduled removal date:
- Click Edit next to the individual targeting rule.
- Click the red calendar icon next to the individual context.
- Update the removal date, and click Save. To remove the date completely, click Remove.
The removal date is now updated.
You can also use the REST API: Update expiring context targets for feature flag