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

# Klaviyo

> Connect Klaviyo for automatic click attribution and optional Shopify revenue reporting.

When you finish, Datalyr attributes Klaviyo email and SMS clicks. Shopify stores can also import campaign and flow revenue reports.

## Before you start

| Requirement               | Detail                                                                                     |
| ------------------------- | ------------------------------------------------------------------------------------------ |
| Datalyr access            | You must be a workspace owner or admin                                                     |
| Klaviyo access            | Your Klaviyo user must be able to approve an OAuth app                                     |
| Web tracking              | The linked site must have the [Datalyr web tracker](/getting-started/install-web-tracking) |
| Shopify revenue reporting | Optional. Shopify must send `Placed Order` events to the same Klaviyo account              |

You do not need Shopify or a conversion metric for click attribution.

## Connect Klaviyo

<Steps>
  <Step title="Open Sources">
    Open **Sources**. Find the **Klaviyo** card.
  </Step>

  <Step title="Start the connection">
    Select **connect**.
  </Step>

  <Step title="Sign in">
    Sign in to the Klaviyo account that you want to connect.
  </Step>

  <Step title="Approve access">
    Review the access request. Select **Continue**.
  </Step>

  <Step title="Confirm the account">
    Return to Datalyr. Confirm that the Klaviyo panel shows the correct account.
  </Step>
</Steps>

Datalyr uses OAuth, so you do not supply a private API key. The connection refreshes its authorization automatically.

## Set up click attribution

<Steps>
  <Step title="Open the Klaviyo panel">
    Select the connected **Klaviyo** card in **Sources**.
  </Step>

  <Step title="Configure the tracking settings">
    Select **Set up click attribution**.
  </Step>

  <Step title="Check the result">
    Confirm that **Attribution** reads `Ready`.
  </Step>
</Steps>

Datalyr writes three custom parameters to the Klaviyo account tracking settings. Datalyr reads the settings again before it shows `Ready`.

| Parameter        | Klaviyo value                         | Purpose                                 |
| ---------------- | ------------------------------------- | --------------------------------------- |
| `dl_ksource`     | Static value `klaviyo`                | Identifies Klaviyo as the visit source  |
| `dl_kmessage_id` | Campaign ID or flow `message_name_id` | Identifies the campaign or flow message |
| `dl_kprofile_id` | Klaviyo Profile ID                    | Links the visit to the Klaviyo profile  |

Datalyr keeps all existing UTM parameters. You do not add these parameters to each message.

New messages use the account tracking settings by default. Klaviyo does not add the parameters when message tracking is off.

The web tracker removes `dl_kprofile_id` from the browser address after it records the value. The next event stores it as `external_ids.klaviyo`.

If marketing consent is denied, Datalyr removes the parameter and does not store the Klaviyo Profile ID.

## Add Shopify revenue reporting

Skip this section if you only need click attribution. SaaS and other non-Shopify businesses do not need a conversion metric.

<Steps>
  <Step title="Open Klaviyo metrics">
    In Klaviyo, open **Analytics → Metrics**.
  </Step>

  <Step title="Find the Shopify metric">
    Confirm that `Placed Order` has the Shopify icon.
  </Step>

  <Step title="Open the Datalyr source">
    In Datalyr, open **Sources**, and then select the connected **Klaviyo** card.
  </Step>

  <Step title="Refresh the metric list">
    If Datalyr does not show `Placed Order`, select **Refresh metrics**.
  </Step>

  <Step title="Select the conversion metric">
    Select `Placed Order` from Shopify.
  </Step>
</Steps>

Datalyr imports these Klaviyo campaign and flow fields:

| Group            | Fields                                                       |
| ---------------- | ------------------------------------------------------------ |
| Delivery         | Recipients, delivered messages, unique opens, unique clicks  |
| Conversion       | Conversions, conversion value, conversion rate               |
| Rates            | Open rate, click rate                                        |
| Datalyr visits   | Visitors, sessions                                           |
| Message identity | Campaign or flow ID, message ID, name, channel, period start |

Klaviyo calculates `Placed Order` value as subtotal plus shipping, less discounts. Klaviyo does not subtract canceled or refunded orders.

The reported value is gross placed-order revenue. It is not net revenue after cancellations and refunds.

## Verify click attribution

<Steps>
  <Step title="Create a test message">
    Create a Klaviyo test message that uses the account tracking settings.
  </Step>

  <Step title="Add a tracked link">
    Add a link to a page that has the Datalyr web tracker.
  </Step>

  <Step title="Send the message">
    Send the message to your test recipient.
  </Step>

  <Step title="Open the link">
    Select the link in the received message.
  </Step>

  <Step title="Open attribution">
    In the Klaviyo source panel, select **Open attribution**.
  </Step>

  <Step title="Find the visit">
    Select a date range that includes the test. Confirm that Klaviyo appears as the source.
  </Step>
</Steps>

For Shopify reporting, return to the Klaviyo source panel after the next data sync. Confirm that the last 30 days show message metrics.

## When it does not work

| Symptom                                              | Cause                                                            | Check                                           | Fix                                                                             |
| ---------------------------------------------------- | ---------------------------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------- |
| Attribution reads `Reconnect`                        | The connection does not have tracking-settings access            | The status in the Klaviyo panel                 | Select **Reconnect Klaviyo**. Approve the new access                            |
| The panel shows **Retry verification**               | Datalyr could not read the Klaviyo tracking settings             | The Klaviyo connection is active                | Select **Retry verification**                                                   |
| `Placed Order` is not listed                         | Shopify has not sent that metric to this Klaviyo account         | **Analytics → Metrics** in Klaviyo              | Confirm the Shopify connection. Send one test order. Select **Refresh metrics** |
| Attribution reads `Ready`, but no test visit appears | The message has tracking off, or the page has no Datalyr tracker | The link query and the page event in **Events** | Turn on message tracking. Install or correct the web tracker                    |
| The visit appears without a message match            | The link has no `dl_kmessage_id`                                 | The query parameters on the received link       | Use the Klaviyo account tracking settings for that message                      |
| Klaviyo revenue exceeds Shopify revenue              | Klaviyo does not subtract canceled or refunded orders            | Canceled and refunded orders in the date range  | Compare gross placed-order revenue, or use Datalyr net revenue reports          |

## Disconnect Klaviyo

Open **Sources**. On the connected **Klaviyo** card, select the control labeled **Disconnect**.

Datalyr stops the Klaviyo reporting sync. Datalyr also removes the imported Klaviyo reporting data for that connection.

## Next

* [Install web tracking](/getting-started/install-web-tracking): record the visits that start from Klaviyo links.
* [Attribution](/attribution/index): learn how Datalyr assigns source credit.
* [Missing attribution](/troubleshooting/missing-attribution): check a visit that has no expected source.
