If you want to rollout a feature flag to a group of users, you will need to:
- create custom data;
- set the value of the custom data by using our SDK method addData();
- create a segment by combining several of your custom data.
Create a custom data
On the side menu of the back-office, click on “Configure” > “Advanced tools” and then hit the “New” button.
Choose the “Custom data” type and select your site/property.
Name your custom data, choose the “Kameleoon Activation API” acquisition method, the type of your custom data (“String”, “Boolean” or “Number”) and the scope “Visit”. Those are the settings compatible with our feature flag product.
Set the value of the custom data by using our SDK
To associate various custom data with the current user, you need to use the addData() method of our SDK (please read the technical documentation of our SDK). This method has to be called before you activate your feature flag with the method activateFeature().
Note that the addData() method doesn’t return any value and doesn’t interact with the Kameleoon back-end servers by itself. Instead, all declared data is saved for further sending via the flush() method. This reduces the number of server calls made, as data is usually grouped into a single server call triggered by the execution of flush().
See an example of code below:
kameleoonClient.addData( visitorCode, new Data.CustomData(10, "Brand name 1") ); kameleoonClient.flush(visitorCode);
Note that you will need to use the unique id of the custom data (in the code above, the ID is 10). This index can be found once the custom data is created, by hovering over the custom data line.
Create a segment by using your custom data
To create a segment, simply hit the CTA “Create a new segment” from the feature flag configuration page. The segment builder will open and you will be able to use your custom data and set the value(s) you want to target. You can combine several of them with AND/OR.