> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abconvert.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Klaviyo Integration: Test Groups in Klaviyo and Segments as Audiences

> Send each visitor's test group to their Klaviyo profile, and target tests at the people in a Klaviyo segment.

<Warning>
  **Pre-release.** This guide applies when the Integrations hub is enabled for your ABConvert account.
</Warning>

The Klaviyo integration works in both directions. ABConvert sends an event to a visitor's Klaviyo profile when they enter a test, so you can build Klaviyo segments and flows per test group. And ABConvert can read your Klaviyo segments, so a test can target only the people in one, or everyone outside it.

## Send test groups to Klaviyo

### What gets sent

When a visitor is assigned to a test, ABConvert records one `Entered ABConvert Test` event on their Klaviyo profile with these properties:

| Property           | Description                      | Example               |
| ------------------ | -------------------------------- | --------------------- |
| `test_id`          | The numeric test ID, as a string | `"49603"`             |
| `test_name`        | The test name                    | `"Hoodie price test"` |
| `test_group_index` | The test group index             | `1`                   |
| `test_group_name`  | The test group name              | `"Variant A"`         |

The event fires once per visitor per test, on the page where the visitor is assigned. A visitor who lands in a different test group later gets a new event.

```json theme={null}
{
  "metric": "Entered ABConvert Test",
  "properties": {
    "test_id": "49603",
    "test_name": "Hoodie price test",
    "test_group_index": 1,
    "test_group_name": "Variant A"
  }
}
```

### Setup

<Steps>
  <Step title="Turn on Klaviyo onsite tracking">
    The Klaviyo app for Shopify installs Klaviyo's onsite script on your storefront. ABConvert uses that script, so no API key is needed for this part.
  </Step>

  <Step title="Turn on the integration">
    In ABConvert, go to **Integrations**, find **Klaviyo** under Marketing, and turn the switch on.
  </Step>

  <Step title="Verify the connection">
    Land in a running test as an identified visitor, for example by opening your store from a Klaviyo email. In Klaviyo, open your profile and look for `Entered ABConvert Test` in the activity feed. The Integrations page can show **Connected** after ABConvert successfully hands the event to Klaviyo's browser queue. Confirm the activity feed before treating this as Klaviyo receipt.
  </Step>
</Steps>

### Using the event in Klaviyo

* **Segment:** "What someone has done: Entered ABConvert Test at least once, where `test_name` equals *Hoodie price test* and `test_group_name` equals *Variant A*."
* **Flow:** trigger on the `Entered ABConvert Test` metric and split on `test_group_name` to send a different message per test group.
* **Campaign:** send to the segment above.

### Things to know

* Klaviyo attaches events to profiles it has identified. When anonymous visitor tracking is enabled in Klaviyo and the visitor grants the required consent, Klaviyo can retain activity in that browser for up to 14 days and attach it after identification. Shopify checkout identification also requires Klaviyo Shopify additional tracking. Visitors who never identify are not recorded.
* ABConvert's current integration handoff is not an independent consent gate. Configure Klaviyo and your consent manager to suppress collection when consent is denied, then verify the real browser behavior before relying on it.
* Klaviyo's onsite script runs on storefront pages, not inside checkout, so tests that only change checkout do not send this event.
* Renaming a running test changes `test_name` for visitors assigned after the rename. A segment built on the old name stops growing.

## Target by Klaviyo segment

### How it works

Add a **Klaviyo segment** condition to a test's audience, choose a segment, and pick *is in* or *is not in*. When a visitor arrives, ABConvert checks whether their Klaviyo profile is in that segment and decides whether they enter the test.

Only visitors Klaviyo has identified can be in a segment. Everyone else counts as outside every segment: *is in* excludes them and *is not in* includes them.

### Setup

<Steps>
  <Step title="Create a private API key in Klaviyo">
    In Klaviyo, go to **Settings → API keys → Create Private API Key**. Give it read access to **Segments** and **Profiles** (the `segments:read` and `profiles:read` scopes) and nothing else.
  </Step>

  <Step title="Connect the key in ABConvert">
    In ABConvert, go to **Integrations**, find **Klaviyo audience targeting** under Marketing, click **Connect**, and paste the key. ABConvert checks it with Klaviyo and never shows it again.
  </Step>

  <Step title="Add the condition to a test">
    In the test's Targeting step, open **Advanced conditions**, find **Klaviyo Segment**, and add a condition. Pick the segment from the list and choose *is in* or *is not in*. Two conditions in the same row are OR; a second row is AND.
  </Step>
</Steps>

### Things to know

* ABConvert checks membership at most once an hour per visitor, so a visitor who joins a segment is picked up on their next visit after that. Their test group never changes: a visitor who leaves the segment stops seeing the test, and returns to the same test group if they qualify again.
* A visitor's first page view waits for the membership check, up to about a second and a half. If Klaviyo does not answer in time, the visitor sees your original store on that page and is checked again on the next one.
* ABConvert sends the browser's Klaviyo identifier and the segments your tests reference. It receives back only whether the visitor is in each one. Configure the consent policy for this lookup before you use audience targeting.
* If the key stops working, the Integrations page shows **Action needed**, and tests that target a Klaviyo segment cannot be launched until you connect a new key. Running tests keep serving.
* The segment list refreshes every five minutes. A segment you delete in Klaviyo keeps its id in the test; replace it with a current segment.
