• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
    No results for ""
    EXPAND ALL

    EDIT ON GITHUB

    Individual targeting

    Read time: 3 minutes
    Last edited: Mar 08, 2023

    Overview

    This topic explains how to use a flag's Targeting tab to control which individual contexts receive a variation of a feature flag, based on the context key.

    Assigning individual contexts to a variation

    The "Targets" section of the 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 assign contexts to a flag variation:

    1. Navigate to the flag's Targeting tab.
    2. In the "Individual targets" section, click + Add.
    3. Choose one or more context kinds and click Save.
    The "Available context kinds" menu with one context kind selected.
    The "Available context kinds" menu with one context kind selected.
    1. The "Individual targets" section updates to display the context kinds you selected.
    2. Choose contexts to target with the flag variation.
    Only target small numbers of contexts individually

    We recommend using individual targeting 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. To learn more about targeting many contexts, read Creating targeting rules.

    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 first variation of a flag. That flag is targeted to them. This means that these contexts will receive that flag variation when they access the flag.

    A flag with organization and user contexts targeted.
    A flag with organization and user contexts targeted.

    You can also use the REST API: Individual context targets

    Removing individual targets

    You can remove a context from a flag's targeting list by clicking the "X" next to the context's name. To do this:

    1. Navigate to the flag's Targeting tab.

    2. In the "Targets" section, find the name of the context you wish to remove.

    3. Click the X next to the name to remove the context:

      A user context in the flag's targeting section, with the "X" to remove called out.
      A user context in the flag's targeting section, with the "X" to remove called out.
    4. (Optional) If you need to undo the changes you just made, click the undo arrow icon to discard all changes:

      A feature flag's "discard all changes" button called out.
      A feature flag's "discard all changes" 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 Targeting tab.

    5. Click Review and save.

    Scheduling removal dates for individual targeting

    Scheduling removal dates is a Pro and Enterprise feature

    Scheduling removal dates is available to customers on a Pro or Enterprise plan. 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:

    1. Navigate to the flags list and select the flag for which you want to configure a removal date. The flag's Targeting tab appears.
    2. In the "Targets" section, search for the context you want to target or click the name of an existing context you want to set a removal date for.
    3. Click Add and schedule removal next to the context name. The "Schedule removal" dialog appears.
    The targeting field with the "Add and schedule removal" option called out.
    The targeting field with the "Add and schedule removal" option called out.
    1. Set a date and time for the user context to be removed from the flag:
    The "Schedule removal" dialog to schedule the targeting removal.
    The "Schedule removal" dialog to schedule the targeting removal.
    1. Click Save.
    2. (Optional) If you need to undo the changes you just made, click the undo arrow icon to discard all changes.
    3. Click Review and save.

    The individual targets are now scheduled for removal on the date and time you specified.