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


Building user segments

Read time: 3 minutes
Last edited: Dec 15, 2021


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

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 dashboard.
  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. Segment targeting rules function the same way as flag targeting rules. To learn more, read Targeting users.

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.
  3. Click Add rules to create a custom rule for this segment. The custom rule menu appears:
A user segment screen with the "Add rules" button called out.
A user segment screen with the "Add rules" button called out.
  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.

You can target the same user segment from multiple feature flags. If you have many flags that need the same targeting rules, it may be easier to set up a single user segment with those rules for your flags to target, rather than setting up the rules repeatedly in each flag.

Scheduling user removal from segments

Scheduling removal dates is an Enterprise feature

Scheduling removal dates is available to customers on an Enterprise plan. To learn more, read about our pricing. To upgrade your plan, contact Sales.

You can schedule a date and time on which a user is removed from a segment.

By doing this, you can specify a future date and time after which the user will no longer be a member of that segment. You can do this for existing users, or when you create a new one.

This is useful if you want to give users temporary access to a feature that has their segment targeted. The ability to remove users from segments, instead of flag targeting, allows you to keep your flag's targeting rules permanent and clean.

To set a targeting removal date:

  1. Navigate to the Segments dashboard and choose the segment you wish to modify.
  2. In the "Included users" field, click the user you wish to remove from the segment:
The "Target individual users" screen
The "Target individual users" screen
  1. In the "Remove user on" section, click to expand a calendar view:
The removal scheduling calendar.
The removal scheduling calendar.
  1. Set a date and time for the user to be removed from the segment.
  2. Click Apply.
  • If approvals are not required, the user is now scheduled for removal on the date and time you specified.
  • If approvals are required for scheduled removal dates, click the Request Approval button in the upper right.

The Request Approval screen appears:

The request approval screen.
The request approval screen.
  1. Enter a Description to add context that helps your reviewers understand the changes you made.
  2. (Optional) If necessary, you can edit your flag changes by clicking the Edit button.
  3. Choose one or more reviewers from the Reviewers dropdown.
  4. Click Request approval.

The people you chose from the dropdown each receive an email asking them to approve your flag changes. The flag's Targeting page also updates with an icon to indicate that there are pending changes waiting for review.

Additionally, when you add a user to a segment, you can schedule them for removal later by clicking Add + Schedule Removal.

Here is an image of the user targeting field:

The user targeting field with the "Add + Schedule Removal" option called out.
The user targeting field with the "Add + Schedule Removal" option called out.