Flags within Flagsmith are a combination of both:
- A Boolean value - the
and then optionally:
- A String/Integer/Float value - the
- A selected Multivariate String/Integer/Float - the
You are free to use either the
Flag State, or the
Flag Value or a combination of both
Flag State and
within each flag. You don't have to provide or use a
Flag Value. If you just want a boolean flag, you can just ignore
Flag Value altogether.
This allows you to use Flagsmith in the multiple ways:
- Showing and hiding features in your application. E.g. Controlling a new User Interface element within your application
using the boolean
- Configuring environment variables/keys in your application. E.g. Setting the database URL for your API using the
Flag Value, or setting the Google Analytics API key in your front end.
- Configuring String values used within your application remotely. E.g. You might want to define different colour schemes for your application banner depending on the Environment.
If you provide a
Flag Value to a flag, this will always be included and returned within the
Flagsmith SDKS and API, regardless of the boolean
You can create a new feature flag by going to the Flags page within any Environment and hitting the Create Feature button.
Flags default to On (true) or Off (false). You can also optionally store and override String and numerical (int and
float) values. The Flagsmith SDKs allow you to call both
hasFeature as well as
getValue on the same flag. These
calls will retrive both the Boolean value as well as the String/Numerical value if specified. The SDKs generally return
False/Null if the flag is missing or the value is not set, but there are variations between different languages.
This feature is currently in beta. Please contact us if you need more help with this feature!
You can create a Multivariate Flag if you want the
Flag Value to be one value out of a selection that you define. Each
Environment within a Project can then define and select which value to return based on this list. Multivariate Flags are
useful in 2 core use-cases:
- You want to be able to control the
Flag Valuefrom a pre-selected list.
- You want to run an A/B test. Learn more here.
Multi-Variate Flag values are defined as a "Control" and "Variations". The Control value is always sent as the Flag Value when you get the Flags for the Environment without passing in a User Identity.
The Control and Variant weightings 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, you will always receive the Control value.
If you are getting the Flags for an Identity, the Flagsmith engine will send the value based on the defined Weightings, as specified within the Environment.
In the screenshot above, roughly half our user population will receive the value
normal, roughly one quarter (25%)
large and roughly one quarter (25%) will receive
huge. Note that you can use 100% as a weighting to
ensure all your users receive the same variant.
Multi Variate values can be defined differently for each Environment within your Project.
The primary use case for using Multi-Variate flags is to drive A/B tests.