Create a feature flag

portrait de l'auteur Julie Trenque

Written by Julie Trenque

Updated on 02/15/2022

3 min


Was this content useful?

What is feature management and feature experimentation?

This guide is designed to help you create and activate Feature flags in your mobile application (Android or iOS) or your website. For each use case, we provide SDKs in the main languages (PHP, Java, Swift, NodeJS…). You can have the complete list of our SDKs and follow the installation guidelines provided for each SDK.

Create a new site / property

Before creating any feature flag, you need to create a new site/property in your Kameleoon account. A site can be an environment (production, staging), a website or your mobile application (Android or iOS). 

Each site has its own sitecode, which uniquely identifies a site in your Kameleoon account. If you want to run feature flags across several of your applications and websites without having to duplicate them on each site, we recommend you set up only one site and use the same sitecode in all our SDKs.

Note: Your sitecode appears automatically in the feature flag creation page.

The sitecode is really important and it will be required in our SDK when you initialize the KameleoonClient object.

NodeJS SDK example

Create a new feature flag

Access the Feature flag creation page

On the side menu of the App, click on “Feature flags” to access the dedicated dashboard.

Then click on the “New feature flag” button.

Name your feature flag and choose the site / property on which you would like to activate this feature flag.

A feature key is automatically generated based on your feature flag name. You can update it based on your preferences.

Note: The feature key is the unique ID that enables you to identify the feature flag in your source code. Make sure to update it here before editing it in your source code.

Technical note: Check that the flag has been created and that you can retrieve it from your source code by using our SDK (by calling the activateFeature() method”). Then go back to the Kameleoon interface of your feature flag and continue the configuration steps.

You can associate a tag (which you can use to filter the dashboard list) and/or a description.

By default, your flag is OFF. You will be able to activate it once configured.

Structure of the Feature flag creation page

The Feature flag creation page consists of several blocks.

  • A header indicating the name of the flag, the associated sitecode (you can copy and paste it directly from here) and the feature key.
  • Two main tabs:
    • Environments (to set up your feature flag on each environment)
    • Rollout (to define a rollout strategy for each environment)
  • A footer to view the date of the last backup, save the flag or delete it (via the 3-point menu).


This tab is divided into: Development, Staging and Production. You will be able to define and apply different configurations (dedicated variables, goals and targeting) for your flag, based on the environment it is deployed on.

Technical note: With Kameleoon multi-environments feature flagging, you will have the possibility to use a new parameter named “environment” within the YAML configuration file to define environment types. In the case there is no environment specified within your YAML file, the configuration associated with the “Production” environment from your feature flag edition page will be applied by default.

For example, you can:

  • Activate your flag on two of your environments, Staging & Development;
  • Deactivate your flag on your Production environment.

Note: When your flag is ON on an environment, the circle on the left is green. When your flag is OFF, the circle is grey. When your flag is planned, the circle is blue.

Variables & code

This step is optional.

Here you can configure variables and find some code examples depending on your SDK.

  • Variables

Optionally, you can define feature variables (Number, Boolean, String or JSON) to remotely update the content of your feature flags in production. There is no limitation in the number of feature variables you can create.

For example, if you 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 to update your code remotely once the feature is live.

Note: Once the code is in production, you can change the value of this variable from Kameleoon without having to edit your code. For example, if you change the value from your flag configuration page on Kameleoon, it will automatically impact your flag in your source code.

  • Code examples

Choose your SDK language and use the sample code to set up the SDK in your application. The available languages are the following:

  1. Android
  2. Swift
  3. Java
  4. C#
  5. Node JS
  6. PHP
  7. Ruby
  8. Go
  9. Flutter
  10. Python


This step is optional.

Choose a goal/KPI you want to measure in our reporting tool for this feature flag.

With this tab you can monitor specific KPIs if you wish. For example, you can see if the feature is being used, set up a click tracking…


This step is compulsory.

  • Targeting

You can rollout your feature flag to specific groups of users who share common attributes. For this, you will need to define custom data and then build segments by combining custom data with OR/AND operators.

  • Exposition

You can also set the percentage of your segment that will be exposed to your feature.


This tab enables you to define a release strategy for your feature. It gives you an overview of the flag state and configuration for each environment type.

You can: edit your flag, activate/deactivate it, set up a release schedule.

Note: By default, your feature flag is configured on “OFF” on each environment. This means that none of your users are exposed to this functionality.

Release management

You can either activate and release your flag immediately or schedule its release.

  • Schedule

To schedule the activation of your flag, click on the “Schedule” button.

You can set a specific timezone for your planning thanks to a dropdown displayed at the top of the pop-in.

By default, the selected timezone will be the one set for your customer account. You can then update it independently for each feature flag.

  • Turn on

Once you are happy with your configuration, you can click on the CTA “Turn ON” to activate the feature. You will need to use our SDK methods to retrieve the feature flag configuration and activate it from your application or website.

  • Turn off

You can turn off your flag. This means that none of your users will be exposed to this functionality.

To learn how to manage your feature flags once created, please read our article on the Feature flags Dashboard.

Implementation guidelines

Once your feature flag has been launched / activated, you will need to follow the developer documentation available for each SDK. In a nutshell, you will need to :

  • Install the SDK in your app or website. For web SDKs, you will need to provide credentials (client_id and client_secret) via a configuration file available in the SDK, which can also be used to customize the SDK behavior. You can ask your credentials to your Account Manager.
  • Initialize the KameleoonClient. Remember: you will need your sitecode here.
  • Activate the feature flag by calling the activateFeature() method of our SDK. This method usually takes a visitorCode and the featureKey (the one you have chosen when you have created your feature flag). The activateFeature() method returns a boolean value: true if the user should have this feature or false if not. Kameleoon will randomly expose your visitor to your feature flag (except if you have rolled out it to 100% of your users). If you have set up a segment for your feature flag, Kameleoon will only activate the feature if the user meets the conditions defined in your segment. For mobile SDKs, the initialization of the Kameleoon Client is not immediate, as it needs to perform a server call to retrieve the current configuration for all active feature flags. The runWhenReady() method of the KameleoonClient class allows to pass a callback function that will be executed as soon as the SDK is ready for use. It also allows the use of a timeout. Two methods must be implemented: onReady() and onTimeout(). The onReady() method will be called once the Kameleoon client is ready, and should contain the code that activates your feature flag. The onTimeout() method will be called if the specified timeout happens before the client is initialized.
  • (Optional) Retrieve the feature variables associated with your feature flag by calling the obtainFeatureVariable() method of our SDK. This method takes two input parameters: your feature Key and your variable Key. It will return the data as a java.lang.Object instance. Usually it should be casted to the expected type (the one defined on the web interface).
  • (Required if you use a segment in your feature flag) You can associate data with the current user. For this, you need to use the addData() method of our SDK. Data associated with the current user via this method is not sent immediately to our servers. It is stored and accumulated until it is sent automatically by the activateFeature() or trackConversion() methods, or manually by the flush() method. This allows you to control exactly when the data is flushed to our servers.
  • Track metrics to measure the success of your feature flag. You need to use the trackConversion() method. This method requires a visitorCode and a goal ID to track conversion on this particular goal. In addition, this method also accepts revenue as a third optional argument to track revenue. Only custom goals can be tracked in feature flags reports. The ID you need to use in the trackConversion() method is available in the custom goal creation popin.

  • In this article :