Targeting individual users
Targeting rules allow you to enable Space Mode only for the users you specify in the feature flag.
Previously, when you wanted a flag to evaluate to false, you would turn off its targeting.
This time will be different. To explore the use of flag targeting rules, targeting needs to be enabled.
Instead of making the flag evaluate to false by turning off targeting, you need to change the default value:
- Navigate to the targeting page for the
space-mode
flag in LaunchDarkly. - Scroll down to the default rule near the bottom of the page.
- Change the default rule to serve false instead of true.
- Click Save changes.
Once the flag configuration is saved, the game should update back to dinosaur mode.
Now you'll enable the flag, but only for your user key.
To add a user target:
- Stay on the targeting page for the
space-mode
flag in LaunchDarkly. - Under Target individual users, click Add user targets .
- Click into the Add users box under the True option and enter
user123
. - Click Save changes.
The Space Mode graphics reappear in the game window because your user key is "user123" by default, and the Space Mode flag evaluates to true for that user key.
Try changing users to see what happens:
- Click on the "Toggle Runner" heading.
- Change the key to
user456
. The graphics switch back to dinosaur mode, as your user key no longer matches the targeting rule in the flag. - Change the key back to
user123
. The space mode graphics reappear.
Targeting with individual user keys is effective for differentiating between small sets of users, as long as you know all their user keys. But often you'll want to address larger sets of users, based on different criteria.
On the next page, we'll show you an example of doing this with targeting rules.