Targeting Feature Flags
Targeting feature flags allows you to control which users or groups receive specific features or configurations. In Flagsmith, this is typically achieved using segments, traits, and overrides.
Staged Feature Rollouts
Staged Feature Rollouts allow you to test a new feature with a small subset of your user base. If you're happy with the feature, you can increase the percentage of users that see the feature until it's available to your entire user base.
Staged Rollouts only come into effect if you are getting the Flags for a particular Identity. If you are just retrieving the flags for an Environment without passing in an Identity, your user will never be included in the "% Split" Segment.
To implement staged rollouts:
- Create a Segment with a "% Split" condition (1-100%)
- Connect the segment to your feature flag
- Monitor the feature's performance
- Adjust the percentage as needed
How to Target Features Using Segments
Prerequisites
- A feature flag created in your project
- Basic understanding of Flagsmith segments
- User traits configured in your application
Steps
-
Create a Segment
- Navigate to Segments in the Flagsmith dashboard
- Click Create Segment
- Enter a name for your segment
- Add your first rule:
- Select a trait (e.g., 'subscription_plan')
- Choose an operator (e.g., 'Exactly Matches')
- Enter the value (e.g., 'premium')
- Click Create Segment
-
Set Up Feature Override
- Go to Features in your environment
- Select the feature you want to target
- Click the Segment Overrides tab
- Click Add Segment Override
- Select your newly created segment
- Configure the feature state/value for this segment
- Save your changes
-
Verify Configuration
- Check the segment preview to see matching users
- Test with a user that matches the segment rules
- Confirm the overridden value is returned
What to Do Next
- Monitor segment membership using analytics
- Adjust segment rules if needed
- Add additional segment overrides as required
Your application must identify users and send traits to Flagsmith for segment targeting to work.
Segment Overrides
Segment overrides allow you to control the state or value of a feature for all identities in a segment, without affecting other users.
Example Use Cases
- Roll out a feature to 10% of users in a segment
- Enable a feature only for users on a specific plan
- Show a feature to users with a certain app version
For a hands-on guide to targeting feature flags, see the Transient Traits and Identities tutorial.