|
| 1 | +--- |
| 2 | +id: predefined-variations |
| 3 | +title: Predefined Variations |
| 4 | +description: Learn about free-form values and predefined variations in ConfigCat, how they differ, and when to use each approach for managing feature flag values. |
| 5 | +--- |
| 6 | + |
| 7 | +ConfigCat supports two value-modes for feature flags: _free-form values_ and _predefined variations_. This guide explains the differences between these approaches and helps you choose the right one for your use case. |
| 8 | + |
| 9 | + |
| 10 | +## Overview |
| 11 | + |
| 12 | +In ConfigCat, you can configure feature flags to operate in either of these modes: |
| 13 | + |
| 14 | +- **Free-form values** - Allows arbitrary feature flag values. You can set served values to any value. |
| 15 | +- **Predefined variations** - Constrains feature flag values to a set of variations specified beforehand. You can select served values from a dropdown. |
| 16 | + |
| 17 | +<p> |
| 18 | + <img src="/docs/assets/predefined-variations/usage_192dpi.png" alt="Clone feature flag" width="1366" height="768" decoding="async" loading="lazy" /> |
| 19 | +</p> |
| 20 | + |
| 21 | +## Free-form values |
| 22 | +Free-form values are the traditional, unrestrictive mode that lets you enter a feature flag's exact value each time you set it. |
| 23 | + |
| 24 | +<p> |
| 25 | + <img src="/docs/assets/predefined-variations/free-form-create_192dpi.png" alt="Clone feature flag" width="1366" height="768" decoding="async" loading="lazy" /> |
| 26 | +</p> |
| 27 | + |
| 28 | +### Characteristics |
| 29 | + |
| 30 | +- **Direct Input**: You type or input the value directly when setting up flag rules |
| 31 | +- **Ad-hoc Definition**: Values are defined on-the-fly as needed |
| 32 | +- **No Reusability**: Each value must be entered separately for each rule |
| 33 | +- **Simple Setup**: Straightforward for basic use cases |
| 34 | +- **Flexible**: Any valid value can be entered at any time |
| 35 | + |
| 36 | +### Use cases |
| 37 | + |
| 38 | +Free-form values work well when you have simple, one-off configurations where feature flag values are unique and unlikely to be reused. They're ideal when you need quick setup without upfront planning, especially when working with primitive values like booleans or simple strings and numbers. This approach is also suitable when values change frequently or unpredictably. |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +## Predefined variations |
| 43 | + |
| 44 | +Predefined variations allow you to define a set of reusable values upfront when creating a feature flag. These variations can then be selected from a dropdown when setting up flag rules. Each variation consists of three fields: |
| 45 | + |
| 46 | +<p> |
| 47 | + <img src="/docs/assets/predefined-variations/predefined-variations-create_192dpi.png" alt="Clone feature flag" width="1366" height="768" decoding="async" loading="lazy" /> |
| 48 | +</p> |
| 49 | + |
| 50 | +### Variation fields |
| 51 | + |
| 52 | +| Field | Description | |
| 53 | +|-------|-------------| |
| 54 | +| Served value | **Required.** The actual value that feature flag evaluation will return in your application when this variation is selected. | |
| 55 | +| Display name | Optional. A human-readable identifier for the variation displayed in the dropdown. If not provided, a string representation of the served value is displayed instead. | |
| 56 | +| Hint | Optional. Additional context or description to explain when or why to use this variation. It will be visible as a tooltip. | |
| 57 | + |
| 58 | +### Characteristics |
| 59 | + |
| 60 | +- **Defined at Creation**: Variations must be defined when creating the feature flag |
| 61 | +- **Reusability**: Define once, use multiple times across flag rules |
| 62 | +- **Consistency**: Ensures the same values are used throughout your configuration |
| 63 | +- **Dropdown Selection**: Choose from predefined options instead of typing |
| 64 | + |
| 65 | +### Use cases |
| 66 | + |
| 67 | +Predefined variations are ideal when you have a standard set of values used across multiple rules, especially when consistency is critical for things like color schemes, API endpoints, or configuration objects. They work well when multiple team members need to understand what each value represents and you want to prevent typos or invalid values. This approach is particularly valuable when complex values like JSON objects need to be reused, when you need to provide guidance on when to use specific values, and when values are known upfront and relatively stable. |
| 68 | + |
| 69 | + |
| 70 | +## Converting between free-form values and predefined variations |
| 71 | + |
| 72 | +ConfigCat provides an easy way to convert feature flags between free-form values and predefined variations. |
| 73 | + |
| 74 | +### Converting to predefined variations |
| 75 | + |
| 76 | +When you convert a feature flag from free-form values to predefined variations, ConfigCat automatically collects all currently used values from your existing flag rules. These collected values are presented as suggested variations, but you can modify their display names and hints, or even add new variations. |
| 77 | + |
| 78 | +The conversion doesn't affect your deployed applications. |
| 79 | + |
| 80 | +### Converting to free-form values |
| 81 | + |
| 82 | +When you convert a feature flag from predefined variations to free-form values, the actual values from variations are extracted and feature flag values are updated to use the values directly. Display names and hints are irreversibly deleted, leaving only the values. |
| 83 | + |
| 84 | +The conversion doesn't affect your deployed applications. |
| 85 | + |
| 86 | +## Working with predefined variations |
| 87 | + |
| 88 | +### Creating a feature flag with predefined variations |
| 89 | + |
| 90 | +When creating a new feature flag, you can choose between free-form values and predefined variations. |
| 91 | + |
| 92 | +### Managing predefined variations |
| 93 | + |
| 94 | +You can add/remove/modify predefined variations for a feature flag by clicking the related button in any served value dropdowns or by clicking the **Manage predefined variations** item in the kebab (3 dots) menu of the feature flag. |
| 95 | + |
| 96 | +<p> |
| 97 | + <img src="/docs/assets/predefined-variations/manage_192dpi.png" alt="Clone feature flag" width="1366" height="768" decoding="async" loading="lazy" /> |
| 98 | +</p> |
| 99 | + |
| 100 | +You can create additional variations as needed at any time. However, you can only remove a predefined variation if it is not currently in use. |
| 101 | + |
| 102 | +You can modify the display name and hint of predefined variations at any time, but you can only change the served value of a predefined variation if it is not currently in use. |
| 103 | + |
| 104 | +## Variation ID vs predefined variations |
| 105 | + |
| 106 | +ConfigCat also has a feature called _Variation ID_, but this is different from predefined variations, as it is designed primarily for analytics and A/B testing integrations. It is a hashed identifier of the feature flag's served value. |
| 107 | + |
| 108 | +However, since predefined variations require unique served values, there is an inherent connection between the two concepts: a Variation ID uniquely identifies a predefined variation. |
| 109 | + |
| 110 | +Therefore, if you enable the Variation ID feature in your product's preferences as explained [here](../variation-id-for-analytics/#how-to-access-variation-ids), the **Manage predefined variations** dialog will also display the Variation IDs corresponding to the variations. |
| 111 | + |
| 112 | +:::tip |
| 113 | +Learn more about Variation ID [here](../variation-id-for-analytics). |
| 114 | +::: |
0 commit comments