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

    EDIT ON GITHUB

    Segments

    Read time: 2 minutes
    Last edited: Feb 27, 2023

    Overview

    This topic explains how to build and manage segments. Segments let you target groups of contexts by attribute.

    Understanding segments

    Segments are lists of contexts that you can use to manage flag targeting behavior in bulk. Segments are useful for keeping groups of contexts, like beta-users or enterprise-customers, up to date. They allow you to more quickly turn features on or off for certain groups with confidence.

    LaunchDarkly supports two types of segments:

    • Standard segments
    • Big Segments, including Big Segments synced with Amplitude

    Understanding segment types

    There are a few differences between standard segments and Big Segments. You cannot convert a segment from one kind to another after you create it, so choose the kind that best suits your use case when you create it.

    This table explains the differences between standard segments and Big Segments:

    Segment typeNumber of contextsBacked by external data storeSupports uploading contexts from CSVSupports targeting rulesSupports multiple context kinds
    Standard segmentsUp to 15,000
    Big SegmentsMore than 15,000

    Targeting with segments

    There are some differences between flag targeting and segment targeting:

    • Segments are environment-specific. They do not populate in environments other than the one you created them in.
    • Segment targeting can reference another segment only if both segments exist in the same environment, and if you're using a version of an SDK that supports contexts. To learn more, read SDKs.
    Not all SDKs support targeting segments within segments

    To target a segment within another segment, you must be using the latest version of an SDK that supports the feature. To find out which versions of which SDKs support this feature, read the list of SDKs that support contexts.

    If you target a segment within another segment but aren't using an updated SDK, the flag will skip the segment targeting rule and evaluate contexts against the next subsequent rule.

    Like flags, you cannot create a circular reference between two segments, for example, where segment A targets segment B and segment B targets segment A.

    Using the Segments list

    You can view standard and Big Segments on the Segments list.

    From the list, you can filter segments to display only those synced from Amplitude.

    The "Segments" list with the "Amplitude synced cohorts" filter applied.
    The "Segments" list with the "Amplitude synced cohorts" filter applied.

    Creating segments

    To create a new segment:

    1. Navigate to the Segments list.
    2. Click Create segment. The "Create a segment" panel appears.
    The "Segments" list with the "Create segment" button called out.
    The "Segments" list with the "Create segment" button called out.
    1. Give your segment a human-readable Name.
    2. Enter a Key for the segment. This field auto-populates based on the segment name, but you can change it if you need to.
    3. (Optional) Add a Description.
    4. (Optional) Choose Tags from the menu.
    5. Select the Standard option to create a standard segment, or the Big option to create a Big Segment. You cannot convert a segment from one kind to another after you create it.
    The "Create a segment" panel.
    The "Create a segment" panel.
    1. Click Save segment. The segment's Targeting tab appears.

    You can further edit the segment's settings from its Settings tab.

    You can also use the REST API: Create segment

    Converting a rule into a standard segment

    You may require complex targeting rules to successfully perform feature launches. You can convert both individual targets and targeting rules into standard segments from the flag's Targeting page.

    To convert a rule to a standard segment:

    1. Navigate to the flag's Targeting tab.
    2. In the targeting section or the rule matching section, click the overflow menu of the rule you wish to convert. The overflow menu appears.
    3. Click "Convert to segment". The "Convert to segment" dialog appears.
    A flag rule with the "Convert to segment" option called out.
    A flag rule with the "Convert to segment" option called out.
    1. Give your segment a human-readable Name and a Key.
    2. (Optional) Add a Description.
    3. (Optional) Choose any Tags from the menu menu.
    4. Click Save segment. A confirmation appears indicating that you've created a new segment.

    A new rule targeting the newly created segment appears in the list of targeting rules.

    Deleting segments

    To delete a segment, find the segment you want to delete on the Segments list and click Delete.

    You can also use the REST API: Delete segment

    Here are the topics in this category:

    • Standard segments
    • Big Segments
    • Syncing Big Segments from Amplitude cohorts
    • Bulk editing contexts in segments