Skip to main content

Heap Cohorts

note

This feature is in open beta and active development. Contact the Kameleoon support team for help with this integration.

Heap is a product analytics tool that helps businesses track user behavior, analyze data, and improve their digital products to boost engagement and growth.

You can use the Kameleoon Heap Cohorts integration to sync segments from Heap with Kameleoon.

Key benefits

  • Seamless cohort sync: Import user segments from Heap into Kameleoon effortlessly.
  • Personalized targeting: Deliver tailored experiences based on user behavior.
  • Enhanced experimentation: Run precise A/B tests on specific audience groups.
  • Real-time updates: Keep user segments up-to-date automatically.

Use cases

Optimize experiments with behavioral targeting

You can sync Heap segments with Kameleoon to test variations on users based on their real-time behavior.

For example, you might run an A/B test on users who have viewed a product page multiple times but haven't added anything to their cart. You could then test different incentives (such as limited-time offer versus social proof messaging) to determine which strategy drives the most conversions.

Analyze results with behavioral segmentation

You can break down Kameleoon campaigns using Heap cohorts for deeper insights.

For example, if a test or personalization campaign shows a drop in conversions, you can analyze key Heap segments (such as high-value customers or churn-prone users) to identify patterns. Heap segments help you understand which experiences resonate best with different user groups, so you can refine your strategy.

Personalize experiences using Heap's rich user insights

You can leverage Heap's deep user data—such as behavior, lifecycle stage, or purchase history—to create highly relevant experiences in Kameleoon.

For example, you might identify frequent buyers, users who recently downgraded their subscription, or those who engage with specific content. You can then tailor messaging, promotions, or feature recommendations in Kameleoon to maximize engagement and conversions.

Get started

Generate your Contentsquare ID tokens

To generate your Contentsquare ID tokens:

  1. Open Contentsquare, and navigate to Integrations > Developer hub.
  2. Click the desired token.
  3. Copy the token's ID.

Enable the Heap Cohorts integration in Kameleoon

To use Heap segments, you must first enable the integration in Kameleoon.

  1. Log in to the Kameleoon Admin Console.
  2. Go to Admin > Integrations.
  3. Locate Heap Cohorts and click Install.
  4. Select your project.
  5. Paste your Heap App ID (or specific integration token provided by Heap) in the designated field.
  6. Click Validate.

Configure custom data for Heap segments

To target Heap segments in your experiments, you must set up custom data in Kameleoon. The custom data allows Kameleoon to retrieve the cohort names for each user.

For client-side experiments

  1. Go to Configure > Custom data.
  2. Click New custom data.
  3. Configure the following settings:
    • Name: Heap Cohorts
    • Project: Select your project.
    • Retrieval method: Custom JavaScript code
    • Type: List
    • Format: String
    • Scope: Page
  4. Insert the following snippet into the code field:
Kameleoon.API.Data.retrieveDataFromRemoteSource("HEAP_COHORTS_" + Kameleoon.API.Visitor.code, function(data) {
// Expected data format:
// "HEAP_COHORTS_user2@email.com": {
// "cohorts": ["1338065"]
// },
if (data?.cohorts) {
data.cohorts.map(function(segment) {
Kameleoon.API.Data.setCustomData("Heap Cohorts", segment);
});
}
});

return { "value": null }

For server-side experiments

  1. Go to Configure > Custom data.
  2. Click New custom data.
  3. Configure the following settings:
    • Name: Heap Cohorts
    • Project: Select your project.
    • Retrieval method: Kameleoon SDK
    • Type: List
    • Format: String
    • Scope: Page
  4. Implementation: Refer to your specific SDK's documentation for instructions on using the getRemoteData() method. This method fetches data stored by Heap on Kameleoon servers and makes it accessible in your backend code. For example, see the Go SDK documentation.

Fetch Heap segment names in Kameleoon

To display human-readable segment names in the Kameleoon targeting menu (instead of just IDs), you must fetch the segment map.

  1. In the final step of the custom data creation (or by editing your existing Heap Cohorts custom data), enable the Save the values for the targeting condition associated with the custom data point option.
  2. Insert the following snippet into the dedicated field:
var xhr = new XMLHttpRequest();
// Replace ADD_YOUR_SITECODE with your real sitecode
xhr.open("GET", 'https://data.kameleoon.io/map/map?siteCode=ADD_YOUR_SITECODE&key=HEAP_COMMON', false);
xhr.send(null);
if (xhr.status === 200) {
const data = JSON.parse(xhr.responseText)
var heapSegments = [];
if (
data &&
Object.prototype.hasOwnProperty.call(data, "cohorts") &&
data.cohorts &&
typeof data.cohorts === "object"
) {
Object.entries(data.cohorts).forEach(function ([id, name]) {
heapSegments.push({
value: id,
label: name
});
});
return heapSegments;
}
return [];
} else {
console.error("Error calling for existing custom data values");
return [];
}
info

Replace ADD_YOUR_SITECODE with your actual project sitecode. For guidance on retrieving your site code, see this FAQ entry.

Export Heap segments to Kameleoon

Once you have completed configuration in Kameleoon, you must begin the sync from Heap.

  1. Log in to your Heap account.
  2. Navigate to Data > Segments.
  3. Select the segments you want to export.
  4. Go to the Integrations tab for that segment.
  5. Locate Kameleoon Cohorts.
  6. Enable the sync and set your desired frequency.

Target Heap segments in Kameleoon

You can now use your Heap segments to target users in experiments and personalizations.

  1. Open the Segment Builder in Kameleoon (Settings > Segments).
  2. Click New segment and enter the required information.
  3. Click Next.
  4. Select Technical > Custom data.
  5. Choose your Heap Cohorts custom data.
  6. Select the operator is among the values.

The list automatically populates with your Heap cohort names. Select the cohorts you want to target.