With this integration you can seamlessly connect Kameleoon with Segment.com to:
- push campaign exposure event data (campain name and variation name) to Segment.com, which can then be used by other platforms available in Segment.com marketplace;
- import to Kameleoon Segment events and use them to analyse your campaign results;
- import personas, traits and groups and use them in Kameleoon Segment Builder.
Push Kameleoon exposure events into Segment
Enable Segment integration on Kameleoon
On the Integrations page
Log in to your Kameleoon App, click on “Administrate” and then “Integrations” in the sidebar.

For more information on this page, see our dedicated article.

By default, the tool is not installed. This is signaled by this icon:
With a click on “Install the tool”, you will be able to select the projects on which you want to activate it.

Once you have configured the tool, click on “Validate” in the bottom-right corner: the configuration panel closes. You will then see a “ON” toggle on the right of the tool’s line, as well as the number of projects the tool is configured on.

Exposure events to any campaign will be sent automatically to Segment.com.
Note: make sure the Segment script is installed on your pages as Kameleoon will use Segment API methods to send the data for your campaigns.
Activate Segment.com on a campaign
In an A/B experiment
Once Segment.com is activated on the Integrations page, you can select it as a reporting tool at the “Tracking and goals” step of the finalization panel (or in the Code editor).

In a personalization
Once Segment.com is activated on the Integrations page, you can select it as a reporting tool on the personalization creation page.

On the results page
It is also possible to select it among the reporting tools on the results page.

In the right sidebar, click on “Reporting Tools” and then on “Edit”.

Select Segment.com and don’t forget to validate!
Data transmission
As soon as Segment has been activated and defined as a reporting tool in a campaign, an event called “Experiment viewed” will be sent automatically every time a visitor sees a variation of an active Kameleoon A/B experiment.
Import Segment events, traits, groups and personas into Kameleoon
With this Segment x Kameleoon integration:
- Every event that is triggered by Segment will be automatically sent to Kameleoon, saving developers from having to re-implement an existing Segment Tracking plan in Kameleoon. Page, Screen and Track events will be automatically collected as a Kameleoon custom goal and you will be able to use any of them in your campaigns or to target users doing a specific action on your website or mobile app.
- Track events of type “Audience Entered” or “Audience exited” will be collected as a Kameleoon custom data to be used in our Segment builder to target personas of users.
- Track events of type “identify” with traits will be collected as Kameleoon custom datas to to be used in our Segment builder to target users having specific traits.
- Track events of type “group” will be collected as Kameleoon custom data to to be used in our Segment builder to target a group ID.
Step 1: Generate API Credentials
First, you will have to enable API Credentials in order to use this integration. To learn how to generate the key, please read this documentation.
Step 2: Get your project sitecode
You will also need to get your sitecode in your Kameleoon account.
To learn how to find your sitecode, please read this documentation.
Step 3: Enter this information when setting up the integration in the Segment app
- From the Destinations catalog page in the Segment app, click “Add Destination”.
- Search for Kameleoon in the Destinations Catalog, and select the Kameleoon destination.

- Click on “Configure Kameleoon”.
- Choose which Source should send data to the Kameleoon destination.
- Enter the APIKey and the sitecode in the Kameleoon destination settings in Segment.

Step 4: Matching Users between Kameleoon and Segment
The integration requires that you use the same system of identifiers for both tools, meaning the userId value you pass to Segment should be the same value as Kameleoon uses to identify a “visitor”.
If you use Kameleoon Web Experiment or Kameleoon AI-driven Personalization on your project, Kameleoon places a cookie that contains an anonymous unique identifier, called the Kameleoon visitorcode, randomly assigned to a visitor. This ID is used to uniquely identify a browser. You have several options available:
- You can pass our visitorcode in the userId property of the Segment identify call to ensure Kameleoon can attribute all events data received from Segment to the right visitor.
- You can specify in all subsequent Segment calls an additional user property “
k_visitorCode
“, whose value is the Kameleoon visitorcode. You can retrieve the user visitorCode from the browser by using our Activation APIKameleoon.API.Visitor.code.
Here is an example of a track event call with the user property “k_visitorCode“: analytics.track(‘Add to cart’, {“k_visitorCode”:Kameleoon.API.Visitor.code
}).
- You can pass our visitor code in an additional Segment call as follow:
analytics.track('Kameleoon identifier', {'k_visitorCode': Kameleoon.API.Visitor.code})
. Kameleoon will automatically link the Segment user ID or anonymous ID to our own visitorCode. Make sure to call it only once per session. For instance, you can use this code example in the Global custom script section of the Kameleoon Site property.
Kameleoon.API.Core.runWhenConditionTrue( () => window.analytics && window.analytics.track && window.analytics.user, () => { const kSegmentioIdentifier = window.localStorage.getItem('k_segmentio_identifier'); if(kSegmentioIdentifier && kSegmentioIdentifier === window.analytics.user().anonymousId()) return; window.localStorage.setItem('k_segmentio_identifier', window.analytics.user().anonymousId()); window.analytics.track('Kameleoon identifier', {'k_visitorCode': Kameleoon.API.Visitor.code}) } );
If you use Kameleoon Full Stack Experimentation, please refer to the Kameleoon SDK documentation as you would be able to set your own ID instead of using a generated Kameleoon Visitor Code and so have the exact same one between Segment and Kameleoon.
Step 5: Supported Segment events and Personas
Kameleoon supports the following methods (Track, Identify, Page, Screen, Group), as specified in the Segment Spec.
Behind the scenes, if the Segment event name matches exactly the name of an existing goal in your Kameleoon account, a conversion for this goal will be associated to the visitor. If the goal does not exist, Kameleoon will create a custom goal by using the Segment event name and associate the conversion to the visitor. The goal will appear in the Kameleoon goals page with the name convention ‘SegmentIO [eventType] – [eventName]’. Once the goal has been created, you can use them in any of your campaign.
Segment track calls of type “Audience Entered“, “Audience Exited“, “Identify” and “Group” will be collected as a Kameleoon custom data.
Page
Send Page calls to record whenever a user sees a page of your website, along with any optional properties about the page. Calling page or screen in one of our sources is one of the first steps to getting started with Segment.
For example:
analytics.page('Home', {"k_visitorCode": "oa16i4syt2ve3b0z"});
OR
analytics.page('Home');
Screen
Send Screen calls to record whenever a user sees a screen, the mobile equivalent of page, in your mobile app, along with any properties about the screen. Calling page or screen in one of our sources is one of the first steps to getting started with Segment.
For example:
[[SEGAnalytics sharedAnalytics] screen:@"Home"
properties:@{ @"k_visitorCode": @"oa16i4syt2ve3b0z" }];
OR
[[SEGAnalytics sharedAnalytics] screen:@"Home"];
Segment sends Screen calls to Kameleoon as a screenview
.
Track
Send Track calls to record any actions your users perform, along with any properties that describe the action.
For example:
analytics.track('Login Button Clicked', {"k_visitorCode": "oa16i4syt2ve3b0z"});
OR
analytics.track('Login Button Clicked');
Segment sends Track calls to Kameleoon as a track
event.
Personas, traits and group
Kameleoon allows you to target users based on their belonging to a Segment persona, a group or who have specific traits of properties.
In order to be able to use personas, traits and group IDs in our Segment builder, you will need to set up a custom data in your Kameleoon account for the project of your choice.
Personas
You can choose the name of your choice (eg. SegmentIO personas) and the custom data must be of type “List of string”.

Please follow the guidelines below for Web Experimentation only
If you use our Kameleoon visitor code as your Segment’s User ID in all track event calls, please use the code below in the custom data acquisition method:
window.k_segmentIO = window.k_segmentIO || {}; if(!window.k_segmentIO.runtime) { window.k_segmentIO.runtime = true; const user_id = Kameleoon.API.Visitor.code; Kameleoon.API.Data.retrieveDataFromRemoteSource(`COHORTS_${user_id}`, cohorts => { window.k_segmentIO.cohorts = cohorts && cohorts !== '{}' ? Object.keys(cohorts).filter(key => cohorts[key]) : []; }); } if(!window.k_segmentIO.cohorts || !window.k_segmentIO.cohorts.length) return; return {"value": window.k_segmentIO.cohorts, "overwrite": true};
If you rather use SegmentIO default Identify method to set your own user ID, please use the code below:
if(!window.analytics || !window.analytics.user) return; window.k_segmentIO = window.k_segmentIO || {}; if(!window.k_segmentIO.runtime) { window.k_segmentIO.runtime = true; const user_id = window.analytics.user().id() || window.analytics.user().anonymousId(); Kameleoon.API.Data.retrieveDataFromRemoteSource(`COHORTS_${user_id}`, cohorts => { window.k_segmentIO.cohorts = cohorts && cohorts !== '{}' ? Object.keys(cohorts).filter(key => cohorts[key]) : []; }); } if(!window.k_segmentIO.cohorts || !window.k_segmentIO.cohorts.length) return; return {"value": window.k_segmentIO.cohorts, "overwrite": true};
If you would like to use Segment Personas with one of our SDKs, you will need to follow the guidelines provided in each SDK documentation and use the method retrievedatafromremotesource to retrieve segments for the user. The “key” value to use as the first parameter should follow this format: “COHORTS_{user_id}”.
Then, click on “Advanced settings” and add the JS code below and replace XXXXXXXXX by the Kameleoon Sitecode. To find it, please follow this documentation.
var xhr = new XMLHttpRequest(); xhr.open("GET", 'https://api-data.kameleoon.com/data?key=common&siteCode=XXXXXXXXX', false); var SegmentIOPersonas = []; xhr.onreadystatechange = function() { if(this.readyState === 4) { var segmentIOcohorts = JSON.parse(xhr.response); if (segmentIOcohorts && segmentIOcohorts.cohorts) { segmentIOcohorts.cohorts.forEach(persona => SegmentIOPersonas.push({value: persona, label: persona}) ); } } } xhr.send(); return SegmentIOPersonas;

Click on “Validate” to create the Custom Data.
That’s it! You will now be able to use Segment Personas in our Segment Builder. The list of available personas will be available when you choose the operator “is among the values”.

Traits
To use traits properties in our segment builder to target your campaigns, you will need to create one custom data per trait type. Let’s say for instance that you want to target users based on the “plan” they have subscribed on your website and that you have 3 different plans : freemium, scale and enterprise. You will need to set up a custom data “Subscribed Plan” and the custom data must be of type “string”.
Please follow the guidelines below for Web Experimentation only
If you use our Kameleoon visitor code as your Segment’s User ID in all track event calls, please use the code below in the custom data acquisition method:
window.k_segmentIO = window.k_segmentIO || {};
if(!window.k_segmentIO.runtime)
{
window.k_segmentIO.runtime = true;
const user_id = Kameleoon.API.Visitor.code;
Kameleoon.API.Data.retrieveDataFromRemoteSource(`IDENTIFY_${user_id}
`, segment_identify_properties => {
if(segment_identify_properties && segment_identify_properties.traits && segment_identify_properties.traits.plan){
window.k_segmentIO.plan = segment_identify_properties.traits.plan;
}
});
}
if(!window.k_segmentIO.plan) return;
return {"value": window.k_segmentIO.plan, "overwrite": true};
If you rather use SegmentIO default Identify method to set your own user ID, please use the code below:
if(!window.analytics || !window.analytics.user) return;
window.k_segmentIO = window.k_segmentIO || {}; if(!window.k_segmentIO.runtime)
{
window.k_segmentIO.runtime = true;
const user_id = window.analytics.user().id() || window.analytics.user().anonymousId();
Kameleoon.API.Data.retrieveDataFromRemoteSource(`IDENTIFY_${user_id}
`, segment_identify_properties => {
if(segment_identify_properties && segment_identify_properties.traits && segment_identify_properties.traits.plan){
window.k_segmentIO.plan = segment_identify_properties.traits.plan;
}
});
}
if(!window.k_segmentIO.plan) return;
return {"value": window.k_segmentIO.plan, "overwrite": true};
If you would like to use traits with one of our SDKs, you will need to follow the guidelines provided in each SDK documentation and use the method retrievedatafromremotesource to retrieve segments for the user. The “key” value to use as the first parameter should follow this format: “IDENTIFY_{user_id}”.
You can follow the same guidelines for every trait property you would like to use in the segment builder of Kameleoon.
Group IDs
To use group IDs in our segment builder to target your campaigns, you will need to need to set up a custom data “Group ID” and the custom data must be of type “string”.
Please follow the guidelines below for Web Experimentation only
If you use our Kameleoon visitor code as your Segment’s User ID in all track event calls, please use the code below in the custom data acquisition method:
window.k_segmentIO = window.k_segmentIO || {};
if(!window.k_segmentIO.runtime)
{
window.k_segmentIO.runtime = true;
const user_id = Kameleoon.API.Visitor.code;
Kameleoon.API.Data.retrieveDataFromRemoteSource(`IDENTIFY_${user_id}
`, segment_identify_properties => {
if(segment_identify_properties && segment_identify_properties.groupId){
window.k_segmentIO.groupId = segment_identify_properties.groupId;
}
});
}
if(!window.k_segmentIO.groupId) return;
return {"value": window.k_segmentIO.groupId, "overwrite": true};
If you rather use SegmentIO default Identify method to set your own user ID, please use the code below:
if(!window.analytics || !window.analytics.user) return;
window.k_segmentIO = window.k_segmentIO || {}; if(!window.k_segmentIO.runtime)
{
window.k_segmentIO.runtime = true;
const user_id = window.analytics.user().id() || window.analytics.user().anonymousId();
Kameleoon.API.Data.retrieveDataFromRemoteSource(`IDENTIFY_${user_id}
`, segment_identify_properties => {
if(segment_identify_properties && segment_identify_properties.groupId){
window.k_segmentIO.groupId = segment_identify_properties.groupId;
}
});
}
if(!window.k_segmentIO.groupId) return;
return {"value": window.k_segmentIO.groupId, "overwrite": true};
If you would like to use group IDs with one of our SDKs, you will need to follow the guidelines provided in each SDK documentation and use the method retrievedatafromremotesource to retrieve segments for the user. The “key” value to use as the first parameter should follow this format: “IDENTIFY_{user_id}”.