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.
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.
Create a new feature flag
Access the Feature flag creation page
On the side menu of the back-office, 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. 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 state (ON/OFF).
- Three tabs:
- “Flag” with the key to identify the feature flag in your source code, the possibility to configure variables and some code examples depending on your SDK.
- “Goals” to choose at least a goal/KPI you want to measure in our reporting tool for this feature flag.
- “Rollout” to select the group of users you want to target, define the exposition rate and set up a release schedule.
- A footer to view the date of the last backup, save, turn on the flag or delete it (via the 3-point menu).
The feature key is the unique ID that enables you to identify the feature flag in your source code. It is automatically generated based on your feature flag name. You can update it based on your preferences.
Note: Make sure to update it here before editing it in your source code.
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.
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.
Choose your SDK language and use the sample code to set up the SDK in your application. The available languages are the following:
- Node JS
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 tab enables you to define a release strategy for your feature.
Optionally, 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.
You can also set the percentage of your segment that will be exposed to your feature.
You can either activate and release your flag immediately or schedule its release.
Turn on a feature flag
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.
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.