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.
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.
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
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 a segment is similar to creating a flag.
To add a new segment:
- Navigate to the Segments tab.
- Click New Segment. The "Create a segment" screen appears.
The Segments tab with the New Segment button called out.
- Give your segment a human-readable Name.
- Enter a Key for the segment. This field auto-populates based on the segment name, but you can change it if you need to.
- (Optional) Add a Description.
- (Optional) Choose Tags from the dropdown menu.
- Click Save Segment. The Segment targeting screen appears.
The "Create a segment" screen.
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:
- Navigate to the user segment you wish to modify.
- 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.
- Click Add rules to create a custom rule for this segment. The custom rule menu appears.
- Specify an attribute, operator, and values for the rule.
- If you want to add more criteria, click the plus button beside the rule criteria.
The custom rule menu.
- 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.