Building user segments
Read time: 3 minutes
Last edited: May 14, 2021
This topic explains how to build and manage user segments. User segments let you target groups of users by attribute.
- 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
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.
- 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.
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.
When you are done configuring a rule, click Save Changes.Understanding segment rule logicWhen 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 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:
- Navigate to the Segments dashboard and choose the segment you wish to modify.
- In the "Included users" field, click the user you wish to remove from the segment.
- In the "Remove user on" section, click to expand a calendar view.
- Set a date and time for the user to be removed from the segment.
- 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.
- Enter a Description to add context that helps your reviewers understand the changes you made.
- (Optional) If necessary, you can edit your flag changes by clicking the Edit button.
- Choose one or more reviewers from the Reviewers dropdown.
- 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.