No results for ""
EXPAND ALL
  • Home
  • API docs

GIVE DOCS FEEDBACK

Segments

Read time: 5 minutes
Last edited: Mar 05, 2024
Segments are a Pro and Enterprise feature

Segments are available to customers on a Pro or Enterprise plan. To learn more, read about our pricing. To upgrade your plan, contact Sales.

Overview

This topic explains how to build and manage segments. Segments let you target groups of contexts individually or by attribute. Contexts are people, services, machines, or other resources that encounter feature flags in your product.

Segments are useful for keeping groups of contexts up to date. They let you more quickly turn features on or off for certain groups with confidence. For example, segments are helpful when you want to target a specific group of customers, like beta-users or enterprise-customers, across many different flags, or in an experiment. Like contexts, segments are environment-specific.

We recommend using tags on your segments to help you understand quickly which segments are associated with which projects or teams. To learn more, read Tags.

Understanding segments

There are several ways to define which contexts belong to a particular segment. You can define a segment by any of the following:

  • Using targeting rules. For example, you could create a segment for everyone with an email ending in ".edu", or for all contexts with a "tier" attribute of "enterprise." When you define a segment using targeting, you can include and exclude individual targets and include targets that match specific rules. To learn more, read Rule-based segments.
  • Using a list. For example, if you are collecting the emails of customers who want to participate in beta testing in a spreadsheet, you can define a segment by adding individual targets or by uploading a CSV file. To learn more, read List-based segments.
  • Syncing a list from a third-party application. For example, if you already keep a list of customers in another application, you can define a segment that automatically stays in sync with your external definition. To learn more, read Segments synced from external tools.

Understanding big segments

You may be familiar with the concept of a "big segment," which is a term we previously emphasized in the LaunchDarkly documentation and user interface to describe some segments.

A big segment is a segment that is either a synced segment, or a list-based segment with more than 15,000 entries that includes only one targeted context kind. LaunchDarkly uses different implementations for different types of segments so that all of your segments have good performance.

Most of the time, you don't need to keep track of whether your segment is a big segment or not. For example, you don't need to be aware of this when you are working with existing segments, or when you are using segments in your flag targeting rules.

There are two situations where you need to know whether you are using big segments or not:

  • If you are working with the REST API. Some of the REST API endpoints are specific to big segments. To learn more, read Segments in the API documentation.
  • If you are using server-side SDKs and you are about to create your first synced segment or larger list-based segment in a new environment. Some additional configuration is required. To learn more, read Segment configuration for synced segments and larger list-based segments.

Managing segments

You can create, view, update, and delete segments from the Segments list:

The "Segments" list.
The "Segments" list.

From the list, you can filter segments to display only those matching the criteria you select. You can filter based on tags, either by using the "Tags" filter or by clicking the tag of a segment in the list. You can sort by segment name, or by when each segment was created or last modified.

Creating segments

To create a segment:

  1. Navigate to the Segments list.
  2. Click Create segment.
  3. Choose how you want to define the segment you're creating. To learn more, read Rule-based segments, List-based segments, or Segments synced from external tools.
  4. Click Save segment.

You can also use the REST API: Create segment

Viewing segments and how they're used

To view a segment's details:

  1. Navigate to the Segments list.
  2. Click the Name of the segment.
  3. The segment details page appears, with the Overview tab selected.

The Overview tab displays information about how many contexts the segment can target or is targeting, which flags use this segment in their targeting, and which variations are served to the contexts in this segment:

A segment's "Overview" tab.
A segment's "Overview" tab.

The Targeting tab displays information about which contexts this segment targets. The contexts may be specified individually, by rules, by an uploaded file, or by a third-party application that is synced with LaunchDarkly. If the contexts are specified by a file or if they are synced, you can search for specific contexts that are included in this segment.

Updating segments

To update a segment's details:

  1. Navigate to the segment detail page for the segment you want to update.
  2. Select the Settings tab.
  3. Edit the Name, Description, and Tags for each segment.
  4. Click Save.

To update a segment's targeting:

  1. Navigate to the segment detail page for the segment you want to update.
  2. Select the Targeting tab.
  3. Update the segment's targeting based on the kind of segment:
  • For rule-based segments, add, remove, or edit the segment's targeting rules. To learn more, read Rule-based segments.
  • For list-based segments, add or remove individual targets or upload a new CSV to overwrite or merge with the existing targets. To learn more, read List-based segments.
  • For synced segments, you cannot change segment targeting within LaunchDarkly. Instead, edit the segment in the source application. To learn more, read Segments synced from external tools.

To use the segment in a flag:

  1. Navigate to the segment detail page for the segment you want to update.
  2. Select the Overview tab.
  3. Click Add flag rule.
  4. In the "Add a flag rule to target this segment" dialog, select the flag where you want to use the segment. Then click "Add flag rule."

Alternatively, you can navigate to the Feature flags list and add a new targeting rule directly from the flag's Targeting tab.

Deleting segments

To delete a segment:

  1. Navigate to the segment detail page for the segment you want to update.
  2. Select the Settings tab.
  3. Click Delete this segment.
  4. In the "Delete segment?" dialog, click Delete.

You cannot delete a segment if one or more flags is using it.

You can also use the REST API: Delete segment

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.

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.

Here are the topics in this category:

  • Rule-based segments
  • List-based segments
  • Segments synced from external tools
  • Segment configuration