This feature requires newer versions of our SDKs. The minimum required version for each platform SDK is shown below:
- .NET: 4.0.0
- Go: v3
- Java: 3.0.1
- Node: **4.0
- PHP: 3.0.0
- Python: 5.0.1
- Ruby: 3.0.1
LD Relay: If you are planning to use segments with LD Relay, you will need to upgrade to the latest version 3.0.1 prior to upgrading your SDKs.
If you don't see the Segments tab in your project, please contact email@example.com to confirm that your SDKs are up-to-date so we can enable this new feature for you.
The Segments tab allows you to create targeting rules and lists of users that can be shared by one or more feature flags in an environment. Creating a Segment is a lot like creating a Flag. You can include individual users from a segment. You can also create targeting rules, same as those for flags, that include or exclude users based on attributes your application has provided about those users. Finally, you can explicitly exclude users that would otherwise be included by those rules. This makes it much easier to keep groups of users, such as
enterprise-customers, up to date and allow you to more quickly turn features on or off for certain groups with confidence.
To add a new segment, open the Segments tab from the sidebar
Click on "New Segment" to start creating a segment. In the "Create a segment" panel, you can enter the Name, Key and any additional details for your new segment. In the example below, we create a Segment to target users who have Gmail accounts.
Once you create a new segment, you will see a blank targeting page, very similar to the targeting page you see when you create a new feature flag. Here you can add the same targeting rules that you would for a feature flag.
After clicking "Add rules" at the bottom, we can then add the rule that "email" "ends with" "gmail.com":
Now we can open a flag and create a rule "User is in segment" to target "Gmail Users" using our new segment.
There are a couple of differences between Flag and Segment targeting that you should be aware of.
- Unlike Flags, Segments are only visible in a single Environment.
- Segment targeting cannot reference another Segment.