Rollout by Attribute
This guide explains how to enable a feature for specific users based on their attributes (traits) in Flagsmith using segments and segment overrides. Attributes can include user role, subscription plan, application version, or device type.
Prerequisitesβ
- A Flagsmith project and environment.
- A feature flag created in your project.
- Your application's Flagsmith SDK integrated and configured.
Stepsβ
1. Identify and Send User Traitsβ
Ensure your application is identifying users and sending their relevant attributes (traits) to Flagsmith. For example, you might send traits like plan, email, platform, or version using your SDK:
flagsmith.identify('user_123');
flagsmith.setTrait('plan', 'pro');
flagsmith.setTrait('version', '5.4.1');
2. Create a Segment Based on Attribute(s)β
- Go to the Segments section in the Flagsmith dashboard.
- Create a new segment and add rules that match the attribute(s) you want to target. For example:
plan = proemail Contains @yourcompany.comversion SemVer >= 5.4.0
- You can combine multiple rules for more precise targeting.
3. Apply a Segment Override to Your Feature Flagβ
- In the environment where you want to apply the rollout, go to the Features section and select the feature flag you want to roll out.
- Navigate to the Segment Overrides tab.
- Select the segment you created in the dropdown and set the desired feature flag state or value for users in that segment.
- Save your changes.
Done! Now you can test with users who match (and donβt match) the segment to ensure the feature is enabled/disabled as expected.
Advanced Use Casesβ
- You can combine attribute rules with a % split rule for staged rollouts (e.g., only 10% of "pro" users).
- You can use operators such as
In,SemVer,Modulo, etc., for more complex targeting.
What's nextβ
- Read the segments documentation to understand how they work and their relationship with overrides.
- See the staged feature rollouts guide to combine attribute rules with percentage-based rollouts for gradual releases.
- Understand managing identities to ensure consistent user identification and attribute management across your application.