Integrate Kameleoon with Piano

portrait de l'auteur Julie Trenque

Written by Julie Trenque

Updated on 07/15/2021

2 min


Manage your integrations







Was this content useful?

Piano is a leading subscription, data management and customer experience technology provider with over 300 major media clients. It helps media companies build dedicated audiences and increase revenues.

Within the Piano Suite one can create powerful user segments which may be used for targeted onsite journeys and customized experiences, when being connected to the Kameleoon personalization platform. In order to connect both systems, one will need to set up a custom data within Kameleoon to read the segments for each single user. With the deep custom data bridge, it is also possible to receive the cohort names and IDs, to create individual segments in Kameleoon based on the segments from the Piano DMP.

Custom integration with Piano

Please talk to your Piano Customer Success Manager to get the persistedQueryId, which is tied to your Piano account property. This must be replaced within the JavaScript snippet:

if (typeof window.cX !== 'undefined' && typeof window.cX.getUserSegmentIds === 'function') {

  var segments = window.cX.getUserSegmentIds({persistedQueryId: '1234567890abcdefghijklmnopqrstuvwxyz'});

  if(segments !== '') {

  return {"value": segments, "overwrite":true};

  } else {

return null;


} else {

return null;


Please use the acquisition method “Custom Javascript Code”. This code should be placed in the custom code section of the custom data.

The custom data should be set to the “list of” and “strings” types, the scope may be set to Page, depending on the scope of the segments being defined in Piano; when being set to page it is reevaluated on every page load, if the user is within a certain segment being identified by Piano.

Fetching Piano segment data in Kameleoon

Segment Data is being made available by Piano via a REST-API, which will need another ID. You can verify if your ID is working by calling the full URL within the browser, which should return a list of JSON objects. Please talk to your Piano Customer Success Manager to get this ID and replace it within this snippet:

var xhr = new XMLHttpRequest();"GET", '', false);

var pianoSegments = [];

xhr.onreadystatechange = function() {

if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {

     var piano = JSON.parse(xhr.response); (segment) {

       if ( && !== 'undefined') {

         pianoSegments.push({value:, label:});






return pianoSegments;

Then insert this snippet into the “Advanced settings” of the same custom data.

Using a Piano segment in a Kameleoon segment

After the custom data for the Piano Segments has been set up, you can build segments within the Kameleoon segment builder, by choosing the custom data and selecting “is among the values”, which will then show a list of every segment from the Piano DMP. Selecting one or multiple Piano segments will enable a targeting in personalizations and experiments.

  • In this article :