How to get KPIs and metrics from the Klaviyo API

In this article we will explain how we get your metrics data from Klaviyo to display in MinimalDashboard, but if you want to use this data in your own application you can either use our API or follow the instructions below to write your own implementation.

Klaviyo is a marketing automation platform enabling businesses to create personalized email and SMS campaigns based on customer data. with an extensive API to get list and profile data. You can find their documentation here: Klaviyo's API.

Contents

Authentication

Klaviyo requires a Authentication Header consisting of the string “Klaviyo-API-Key” followed by your private API key you can create here.

Authorization: Klaviyo-API-Key pk_123

Revision

Klaviyo also requires a revision header on all requests.

revision: revision

Endpoint

The primary endpoint for list profiles is: https://a.klaviyo.com/api/lists/<list-id>/profiles.

To get the list id you can use the list endpoint: https://a.klaviyo.com/api/lists/.

You currently can’t get historic data for profiles.

How to get your subscriber count from Klaviyo

To get the current subscriber count send a GET request to:

https://a.klaviyo.com/api/lists/<list-id>/profiles
  // Request expansion of the subscriptions field to establish if the user is surpressed.
  ?additional-fields[profile]=subscriptions

This will all profiles in this specific list.

{
  "data": [
    {
      "type": "profile",
      "id": "01J7ZEJYJ1ETAN34P5BJDE8TRM",
      "attributes": {
        "subscriptions": {
          "email": {
            "marketing": {
              "can_receive_email_marketing": true,
            }
          },
          "sms": {
            "marketing": {
              "can_receive_sms_marketing": false,
            }
          },
          "mobile_push": {
            "marketing": {
              "can_receive_push_marketing": false,
            }
          }
        },
        "joined_group_at": "2024-09-17T07:36:40+00:00"
      },
    },
   ...
  ],
  "links": {
    "next": "...",
  }
}

Using the susbcriptions property you can check for suppression using can_receive_email_marketing, can_receive_sms_marketing or can_receive_push_marketing. Counting all profiles with at least one of these properties ste to true gives you the active subscriber count.

Each request will contain at most 20 items and you can retrieve further pages by using the links.next url, but note you must add the revision and authorization headers.

Looking for more?

Have a look at our API knowledge base with many more services...

icon related to Klaviyo

Klaviyo

Email Marketing

If you'd like to have a ready-made dashboard with all the metrics from Klaviyo instead, you can create one with MinimalDashboard in a few clicks.

Create dashboards to show

  • Active Profile Count
Create your Klaviyo dashboard today