• HOME
  • INTEGRATIONS
  • SDKS
  • GUIDES
  • API DOCS
No results for ""
EXPAND ALL
CLOSE
launchdarkly.com

EDIT ON GITHUB

Building user segments

Read time: 3 minutes
Last edited: May 12, 2020

Overview

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.

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.

Scheduling user removal from segments

This feature requires an Enterprise or Pro plan

Scheduling user removal dates are only available to customers on our Enterprise or Pro plans. To learn more about upgrading your plan, contact Support or your LaunchDarkly account representative.

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.

segments remove user on

  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.
  3. The user is now scheduled for removal from the segment on the date and time you specified.

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

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