Skip to main content

Get Data Out of Klaviyo

Course overview
Lesson
8 min read

Getting data out of Klaviyo

Meet Poppy & Pine, a direct-to-consumer brand that has used Klaviyo for a year. Poppy & Pine sells faux flower bouquets for large scale events: think weddings, major anniversaries, award shows. Their elaborate designs fool even the most passionate of anthophiles (which, in case you were wondering, is a person who loves flowers).

As the business has grown, more teams need to use Klaviyo data in the systems where they already work. But not every team needs that data in the same way.

  • The Analytics team wants campaign and flow performance in BigQuery so they can use it to measure customer health scores.
  • Engineering wants unsubscribes delivered to its CRM in real time, allowing them to prevent any automation blunders.
  • The client-facing team wants periodic segment exports to track any early warning signs.

Each team needs Klaviyo data outside of Klaviyo, but how and when they need it is different. The good news is that Klaviyo offers several ways to get data where it needs to go.

This course covers three patterns for getting data out of Klaviyo: pull, push, and sync:

  • Pull: Request data from Klaviyo when you need it.
  • Push: Have Klaviyo send data when something happens.
  • Sync: Maintain a recurring copy of Klaviyo data in another system.

Klaviyo supports these patterns through APIs and reporting endpoints, webhooks, and Data Warehouse Sync. As you explore each option, you'll see how Poppy & Pine can choose the right approach based on how and when each team needs its data.

Typical export patterns

Pull: You request the data when you need it

What is a pull? A pull asks Klaviyo for data at the time your application, analyst, or integration needs it.

When should I use it? Server-side APIs are a fit when a system needs to retrieve profiles, events, lists, segments, or other API-supported resources on demand. See the Klaviyo API overview. Use Query Metric Aggregates when the question is about aggregated event data such as counts grouped by day, hour, metric, or another supported dimension. Use the Reporting APIs when the goal is to reproduce performance reporting that aligns with what a customer sees in the Klaviyo UI. See the Reporting API overview.

What does this look like? Poppy & Pine’s analytics team schedules Reporting API requests to land campaign and flow performance data in BigQuery. When the team wants to see how much Placed Order revenue each flow brought in per month over the past year, it uses Query Metric Aggregates instead.

Because Query Metric Aggregates counts by when each order happened, not when the flow message was sent, those totals won’t match the flow report in Klaviyo.

javascript
{
    "data": {
         "type": "metric-aggregate",
         "attributes": {
              "measurements": [
                   "sum_value"
              ],
              "by": [
                  "$attributed_flow"
              ],
              "filter": [
                   "greater-or-equal(datetime,2022-01-01T00:00:00)",
                   "less-than(datetime,2023-01-01T00:00:00)",
                   "not(equals($attributed_flow,\"\"))"

              ],
              "metric_id": "PhqdJM",
              "interval": "month",
              "timezone": "US/Eastern"
         }
    }
}

Push: Klaviyo sends data when something happens

What is a push? A push sends information from Klaviyo to an external endpoint in response to an event. Webhooks use HTTP requests to notify another application that an event occurred, and the request can include a payload and authentication headers. See Understand the different webhooks available in Klaviyo.

When should I use it? Flow webhooks run as an action inside a flow. They send a POST request when a flow reaches the webhook step. Flow webhooks can only respond to events that can trigger a flow. Received Email and Clicked Email can't trigger a flow, so a flow webhook can't respond to them.

Advanced KDP webhooks support a broader set of event topics, including message-related events, integration events, and API events. They can also subscribe to multiple triggers and send event data to a publicly accessible HTTP endpoint.

What does this look like? Poppy & Pine’s client-facing team wants every text message conversation in its helpdesk, so they can see what a customer was sent and how they replied. A system webhook subscribed to the Sent SMS and Received SMS topics pushes each of those events to the helpdesk as soon as it happens.

javascript
{
  "data": {
    "type": "webhook",
    "attributes": {
        "name": "SMS Conversation Webhook",
        "endpoint_url": "https://www.example.com/klaviyo-events",
        "secret_key": "sEcReTkEy12345678",
        "description": "This webhook triggers sms sent and sms received events",
    },
    "relationships": {
      "webhook-topics": {
        "data": [
          {
            "type": "webhook-topic",
            "id": "event:klaviyo.sent_sms"
          },
          {
            "type": "webhook-topic",
            "id": "event:klaviyo.received_sms"

Sync: Data moves on a recurring schedule

What is a sync? A Data Warehouse Sync moves selected Klaviyo profile and event data to an external warehouse on a recurring cadence. Klaviyo's documentation describes profiles and events as warehouse data objects, supports selective event sync, and states that periodic syncs occur hourly by default. See Understand data warehouse syncing in Klaviyo. Data Warehouse Sync is part of Advanced KDP, which requires a separate subscription. Learn more about Advanced KDP here.

When should I use it? A warehouse sync is useful when Poppy & Pine's analytics team wants a durable dataset for recurring analysis rather than making a new API request for every report. Poppy & Pine can choose historical data for the initial sync and selectively sync events, but syncing all data may create additional warehouse charges.

No supported data warehouse? Klaviyo's SFTP export tool sends event data to your SFTP directory on a schedule, like every hour or every day, or as a one-time historical export. Files are CSV by default, or JSON. It's a good fit for smaller teams or a homegrown data warehouse. Learn more in Export event data with SFTP.

What does this look like? Poppy & Pine uses Data Warehouse Sync when the analytics team needs recurring profile and event data in BigQuery. The team does not treat that sync as the direct source for campaign and flow performance or as a real-time notification; those needs use the appropriate API or webhook instead.

A preview of the data warehouse syncing control screen in the Klaviyo app

MCP: A conversational interface to pull data through Klaviyo's APIs

What is MCP? MCP connects AI tools like Claude, ChatGPT, or other AI harnesses to Klaviyo, so users can ask questions, pull reports, and analyze performance in plain language. Under the hood, the MCP server wraps Klaviyo APIs. Beyond exporting data, the Klaviyo MCP can also create flows, templates, campaigns, segments, coupons, and manage lists.

When should I use it? Use read-only MCP access when the use case is reporting, exploration, or analysis and the team does not need the assistant to create or modify data.

What does this look like? Poppy & Pine's marketing operations team uses Claude to ask, "Summarize campaign and flow performance for the last 90 days and flag the biggest outliers." That is still a pull: the MCP client provides the conversational interface, while Klaviyo APIs provide the data.

Screenshot of an AI agent interface executing Klaviyo API tool calls to create an email campaign and template for a new product launch.

When to use each export pattern

If your data need is...

Use this method

Why

Retrieve profiles, events, lists, or segments on demand

Server-side API pull

Your system requests the data when it needs it.

Count or aggregate event data by time, metric, or dimension

Query Metric Aggregates

Built for aggregated event analysis.

Match campaign or flow reporting to the Klaviyo UI

Reporting API pull

Intended for performance reporting that aims to match the Klaviyo UI. Numbers can still shift for days as late events arrive, so see the attribution note in Best practices for getting data out of Klaviyo.

React immediately to an event in Klaviyo

Webhook push

Klaviyo sends an HTTP request when the subscribed event occurs.

Maintain a recurring analytics dataset in a warehouse

Data Warehouse Sync

Profile and event data are delivered on a recurring cadence, hourly by default.

You can do all three of these through the MCP server connected to an AI client:

  • Retrieve profiles, events, or segments on demand (like a server API pull)
  • Count or aggregate event data (like Query Metric Aggregates)
  • Match campaign or flow reporting to the Klaviyo UI (like a Reporting API pull)

MCP is the conversational layer that sits on top of Klaviyo, giving you headless access without a manual API call for every question. The above are just a few use cases and you can learn more about the MCP in the Klaviyo MCP Server Guide for Agencies.

Common gotchas

When you're getting data out of Klaviyo, keep an eye out for these common gotchas.

Select a gotcha to expand it.

Treating Query Metric Aggregates as a copy of the Klaviyo UI

What goes wrong: Query Metric Aggregates and Klaviyo UI reporting can produce different results because they are different reporting paths. When the goal is to match what a customer sees in the UI, use the Reporting APIs.

Workaround: Decide whether the requirement is event-time aggregation or UI-aligned performance reporting before selecting the endpoint. Use Query Metric Aggregates for aggregated event questions and Reporting APIs for campaign or flow performance that must match the UI.

Example: Poppy & Pine's analyst uses Query Metric Aggregates to group Placed Order events by day. A stakeholder compares the result with the Klaviyo dashboard and sees a discrepancy. Poppy & Pine reruns the dashboard-style question through the Reporting API instead of trying to force Query Metric Aggregates to reproduce the UI.

Using a webhook when the event is outside the webhook's scope

What goes wrong: A developer tries to build a flow webhook for Clicked Email, but Clicked Email can't trigger a flow.

Workaround: Confirm whether the event can trigger a flow. If the requirement involves message-related events, multiple topics, or broader system events, evaluate Advanced KDP webhooks instead.

Example: Poppy & Pine needs to copy every email click to a help desk system. The team replaces the flow-webhook design with an Advanced KDP webhook subscription that supports message-related events.

Syncing everything to the warehouse by default

What goes wrong: If you don't choose specific events, Data Warehouse Sync sends all of them, including high-volume events like Received Email and Opened Email. Those can outnumber Placed Order events by a wide margin, impacting your warehouse bills.

Workaround: Use Selective sync and Integrations to exclude to send only the events your team needs. For the initial historical sync, start with 30 or 90 days instead of all time.

Example: Poppy & Pine's analytics team only needs order and engagement data for customer health scores. They narrow the sync to those events to keep their BigQuery costs flat.

Activity: Match the scenario with the best export method for the data

Match the scenario with the best export method for the data.
Scenario
A marketing operations team wants Claude to summarize the last 90 days of campaign performance without manually exporting reports.
A CRM needs to receive an unsubscribe event as soon as it happens.
A client-facing team wants a current export of the profiles in a Klaviyo segment every Monday.
A small team without a supported data warehouse wants a daily file of event data in its SFTP directory.
A finance team wants campaign revenue that matches the Klaviyo dashboard.
A developer needs to retrieve one profile's current properties for an internal application.
A data analyst wants daily Placed Order counts by country for the last 90 days.
An analytics team wants profiles and selected events copied to BigQuery every hour.
Export method
SFTP export
Scheduled server-side API pull using the list/segment members endpoint
Data Warehouse Sync
Webhook
Query Metric Aggregates
MCP connected to an AI client using read-only access
Reporting API
Server-side API pull
Getting data out of Klaviyo