LaunchDarkly Developer Documentation

Get started in under 30 minutes.
LaunchDarkly provides feature flags as a service for Java · Python · Ruby · Go · Node.js · PHP · .NET. Control feature launches -- who sees what and when -- without multiple code deploys. Easy dashboard for phased rollouts, targeting and segmenting.
Need more help? write us at

Get Started    Documentation

Building user segments


This topic explains how to build and manage user segments. User segments let you target groups of users by attribute.

This feature is only supported on newer versions of our SDKs

  • Go: v3
  • Java: 3.0.1
  • Node: 4.0
  • PHP: 3.0.0
  • Python: 5.0.1
  • Ruby: 3.0.1
  • .NET: 4.0.0

If you want to use user segments with the LaunchDarkly Relay Proxy, you must upgrade to the latest version 3.0.1 before upgrading your SDKs. To learn more, read The LaunchDarkly Relay Proxy.

You do not need to upgrade mobile (iOS and Android) and client-side Javascript SDKs to use this feature.

If you don't see the Segments tab in your project, contact Support to confirm that your SDKs are up-to-date. If they are, we can enable this feature for you.

Understanding user segments

User segments are lists of users that you can use to manage flag targeting behavior in bulk. You can include or exclude individual users from a segment based on user attributes. Use the Segments tab to create targeting rules and lists of users to manage flag targeting more efficiently.

Segments are useful for keeping groups of users, 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.

There are some differences between flag and segment targeting that you should be aware of:

  • Unlike flags, segments are environment-specific. They do not populate in environments other than the one you created them in.
  • Segment targeting cannot reference another user segment.

Creating user segments

Creating a segment is similar to creating a flag.

To add a new segment:

  1. Navigate to the Segments tab.
  2. Click New Segment. The "Create a segment" screen appears.
The Segments tab with the New Segment button called out.

The Segments tab with the New 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 dropdown menu.
  5. Click Save Segment. The Segment targeting screen appears.
The "Create a segment" screen.

The "Create a segment" screen.

Customizing a user segment

You can customize a segment to apply to different users or attributes, or exclude users and attributes, in the segment's targeting screen.

To customize a segment:

  1. Navigate to the user segment you wish to modify.
  2. Target individual users, or lists of users, with the Included users or Excluded users options. To learn more about bulk user targeting, read Targeting users.
  3. Click Add rules to create a custom rule for this segment. The custom rule menu appears.
  1. Specify an attribute, operator, and values for the rule.
  2. If you want to add more criteria, click the plus button beside the rule criteria.
The custom rule menu.

The custom rule menu.

  1. When you are done configuring a rule, click Save Changes.

Understanding segment rule logic

When you specify rules for a segment, LaunchDarkly parses them in order of appearance from top to bottom. You can change how segment targeting applies based on the order of the rules you create.

Building user segments

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.