Skip to main content
This integration is in open beta and in active development. Contact the Kameleoon support team for help with it.
Klaviyo groups your customers into segments, for example people who viewed a product page several times without adding anything to their cart. Kameleoon can’t use those segments until they reach your Kameleoon project, so the audiences you built in Klaviyo stay out of your campaigns until you connect the two. The integration turns each Klaviyo segment into a cohort that you can select in a segment. You can then use each cohort in a segment for your campaigns.
Table of the data flow from Klaviyo to Kameleoon, which shares cohorts, and the Kameleoon products that support them: Web experiments, Web personalizations, and Feature experiments.

How Klaviyo cohorts fit into your workflow

  • Connect Klaviyo to Kameleoon: Store the Kameleoon visitor code in Klaviyo, and then install the Klaviyo Cohorts integration in Kameleoon.
  • Target Klaviyo cohorts in Kameleoon: Create custom data that holds the cohorts, add the cohort names to it, and then build a segment that uses it.

Before you begin

  • Klaviyo account: An active Klaviyo account with access to the segments you want to use.
  • Klaviyo JavaScript API: Your site loads the Klaviyo JavaScript API, which provides klaviyo.identify().
  • Kameleoon script: Your site runs the Kameleoon script, which provides Kameleoon.API.Visitor.code, the value the snippets in this article read.
  • Project sitecode: The sitecode of the Kameleoon project that receives the cohorts, which you can find as described in manage your projects.

Connect Klaviyo to Kameleoon

Connecting Klaviyo to Kameleoon has two parts. First, your site stores the Kameleoon visitor code on each Klaviyo profile, so each cohort matches the same visitor in Kameleoon. Then the Klaviyo Cohorts integration asks for permission to view profile and segment information, and you grant that permission in Klaviyo.

Store the Kameleoon visitor code in Klaviyo

Add this code to your site after Klaviyo and Kameleoon load, so that Klaviyo stores the visitor’s Kameleoon code on their Klaviyo profile.

Install the Klaviyo Cohorts integration

Install the integration in Kameleoon, and then grant Klaviyo permission to share data with it.
The Klaviyo Cohorts integration card in Kameleoon, with the Use this tool on project list and the Validate button.
  1. Click Admin > Integrations.
  2. Click Klaviyo Cohorts, and then click Install the tool.
  3. In Use this tool on, select the projects where you want to use the integration, and then click Validate. Kameleoon redirects you to Klaviyo.
  4. In Klaviyo, click Allow to let Kameleoon view your profiles and segments.
The Klaviyo permission dialog, asking you to allow Kameleoon to access your profiles and segments.
After you grant permission, the integration exports your Klaviyo cohorts to Kameleoon automatically.

Target Klaviyo cohorts in Kameleoon

After the cohorts reach Kameleoon, you target them with custom data, which Kameleoon reads in each campaign. The retrieval method depends on the product: Web Experimentation uses custom JavaScript code, and Feature Experimentation uses the Kameleoon SDK method. For example, you can run an A/B test on visitors who viewed a product page several times but didn’t add anything to their cart, and compare two incentives, such as a limited-time offer and social proof messaging. On the Results page, you can also break down an experiment’s results by custom data, so you can compare how each cohort responded.

Create custom data for Web Experimentation

Create custom data that reads each visitor’s Klaviyo cohorts in a Web Experimentation campaign.
  1. Click Settings > Custom Data, and then click New custom data.
  2. Enter Klaviyo Cohorts as the name, and select your project. The snippet sets the custom data by this name, so enter it exactly.
  3. Set the Retrieval method to Custom JavaScript code.
The Klaviyo Cohorts custom data form in Kameleoon, with the Custom JavaScript code retrieval method and the snippet in the code field.
Paste this snippet into the code field.
Set Type to List, Format to String, and choose the Scope that fits your test. With the Page scope, Kameleoon resets the value for each new page.

Create custom data for Feature Experimentation

Create custom data that your backend retrieves with the Kameleoon SDK.
  1. Click Settings > Custom Data, and then click New custom data.
  2. Enter Klaviyo Cohorts as the name, and select your project.
  3. Set the Retrieval method to Kameleoon SDK method.
  4. Set Type to List, Format to String, and choose the Scope that fits your test. With the Page scope, Kameleoon resets the value for each new page.
Your backend reads the cohort data with the SDK, using the key KLAVIYO_COHORTS_ followed by the visitor code, and then sets it with the SDK’s addData() method. The Go SDK’s GetRemoteData() method fetches data that Kameleoon stores on its servers for a visitor code or user ID. See the Go SDK documentation for its parameters, and check your SDK’s documentation for the equivalent method.

Add Klaviyo cohort names to the custom data

Add the cohort names so that the segment builder lists each Klaviyo cohort by name instead of by ID.
  1. Click Next to open the options.
  2. Turn on Save the values for the targeting condition associated with the custom data point. A code field appears.
  3. Paste the following script into the code field, and replace {ADD_YOUR_SITECODE} with your project sitecode.
  4. Click Create.
If the request for the cohort names fails, the script returns no values, and the segment builder has no cohorts to select.

Build a segment from Klaviyo cohorts

Build a segment that targets visitors in one or more Klaviyo cohorts.
  1. Click Settings > Segments, and then click New segment.
  2. In the Conditions column, open the Custom data tab, and then select Klaviyo Cohorts.
  3. Select the is among the values condition, and then select the cohorts you want to target.
  4. Choose whether to include or exclude the visitors who match the condition.
Selecting one or more cohorts enables targeting in personalizations and experiments. To learn more about segments, see create a segment.