Define feature variables

Written by Julie Trenque

Updated on 10/08/2024

1 min

Advanced

Was this content useful?

You can define feature variables (Boolean, Number, String, JSON, JavaScript, or CSS) to remotely update the content of your feature flags in your chosen environment. There is no limit on the number of feature variables you can create. Creating feature variables are not necessary, but highly recommended before you create feature variations.

There is no limit on the number of feature variables you can create.

How to create feature variables?

  1. Navigate to your chosen feature flag or create a new one
  2. In the left side menu, go to Variables under the Setup category 
  3. Create a new Variable by clicking the  + Add Variable  button
  1. Select the type, and then edit the Key and Default Value of your variable. 

Types of Feature Variables:

  • Boolean: True or false values.
  • Number: Numeric values for dynamic adjustments.
  • String: Text-based variables for content changes or advanced parsing.
  • JSON: Complex structures for more flexible data handling.
  • JavaScript (JS): Input dynamic JavaScript code for feature releases and experiments.
  • CSS: Customize styles dynamically for enhanced control of UI changes.

Technical note: to retrieve a feature variable in your source code, you’ll need to call the getFeatureVariable() method of our SDK. Please note that if you use feature variations, Kameleoon will automatically bucket the user in a variation and return the value of the variable which has been defined in the variation (ie. you do not need to call the getFeatureVariationKey() method).

Use of JS/CSS Variables:

For JS or CSS variables, the Kameleoon client-side snippet is required to automatically inject the variables into the Kameleoon engine for execution. However, if you prefer to manage the injection yourself, you can still variablize the code via the Kameleoon UI and manually inject it using the SDK.

In both cases, you can use the Kameleoon UI to easily input and handle dynamic JS or CSS code for feature releases and experiments if your SDK version supports this capability.

Why use feature variables?

Feature variables let you variablize parts of your feature flag code so that you can dynamically assign values to variables on the fly depending on your use case, without having to hard code them in your source code. 

Once the code containing your feature variables has been deployed on any of your environments, changing it does not require redeploying. For example, if your feature is a new offer for premium customers but you are not sure about the discount code % you want to offer, you can create a Discount Percentage variable in your code and update it remotely from the app at any time without changing or pushing new code.

Developers and product owners can work in tandem to variablize parts of your feature that are subject to change, so that product updates are not blocked by development and deployments. 

  • In this article :