You will learn
Learn how to export conversion metrics and dates from Klaviyo. If your company houses information in a data warehouse, you will likely want to sync your Klaviyo metrics and conversion data in there as well.
Exporting your metrics
Campaign names (campaign_names)
1. To export campaign names, do the command as shown below.
curl https://a.klaviyo.com/api/v1/campaigns -G \
-d api_key=API_KEY
Unique opens (unique_opens)
When calculating who opens your emails, you can measure for non-unique (the number of total opens, which can include multiple per email address) or unique opens (the number of opens, one per email address).
1. To calculate for unique opens, set up your command as shown below.
curl https://a.klaviyo.com/api/v1/metric/OPENED_EMAIL_METRIC_ID/export -G \
-d api_key=API_KEY \
-d unit='week' \
-d measurement='unique' \
-d where='[["$message","=",'MESSAGE_ID']]'
Open rate (open_rate)
To calculate open rate, take your total delivered (received) emails and divide that by the number of total opens (either unique or non-unique).
1. Calculate the total opens or unique opens of a message ID with the following command:
curl https://a.klaviyo.com/api/v1/metric/OPENED_EMAIL_METRIC_ID/export -G \
-d api_key=API_KEY \
-d unit='week' \
-d measurement='count' \
-d where='[["$message","=",'MESSAGE_ID']]'
2. Then, get the total received or uniques of a message ID with the following command:
curl https://a.klaviyo.com/api/v1/metric/RECEIVED_EMAIL_METRIC_ID/export -G \
-d api_key=API_KEY \
-d unit='week' \
-d measurement='count' \
-d where='[["$message","=",'MESSAGE_ID']]'
3. From there, divide your calculation for opens by deliveries to get your open rate (opens ÷ delivered = open rate).
Unique clicks (unique_clicks)
1. When calculating who clicks into your emails, you can choose to measure for non-unique (the number of total clicks, which can include multiple per email address) or unique clicks (the number of clicks, one per email address), as shown below.
curl https://a.klaviyo.com/api/v1/metric/CLICKED_EMAIL_METRIC_ID/export -G \
-d api_key=API_KEY \
-d unit='week' \
-d measurement='unique' \
-d where='[["$message","=",'MESSAGE_ID']]'
Click rate (click_rate)
To calculate click rate, take the total delivered (received) emails and divide that by the total clicks (either unique or non-unique).
1. Find the number of total clicks or unique clicks of a message ID, as shown below.
curl https://a.klaviyo.com/api/v1/metric/CLICKED_EMAIL_METRIC_ID/export -G \
-d api_key=API_KEY \
-d unit='week' \
-d measurement='count' \
-d where='[["$message","=",'MESSAGE_ID']]'
2. Then, find the total received or uniques of a message ID, as shown below.
curl https://a.klaviyo.com/api/v1/metric/RECEIVED_EMAIL_METRIC_ID/export -G \
-d api_key=API_KEY \
-d unit='week' \
-d measurement='count' \
-d where='[["$message","=",'MESSAGE_ID']]'
3. Next, divide your calculation for clicks by deliveries to get your click rate (clicks ÷ delivered = click rate).
Conversions
1. To calculate conversions, use your desired measurement value (e.g., placed_order), as shown in the command below.
curl https://a.klaviyo.com/api/v1/metric/PLACEDORDERMETRIC/export -G \
-d api_key=API_KEY \
-d unit='week' \
-d measurement='count' \
-d where='[["$attributed_message","=",'MESSAGE_ID']]'
Revenue
1. To calculate revenue, use your desired measurement value (e.g., placed_order), as shown in the command below.
curl https://a.klaviyo.com/api/v1/metric/PLACEDORDERMETRIC/export -G \
-d api_key=API_KEY \
-d unit='week' \
-d measurement='value' \
-d where='[["$attributed_message","=",'MESSAGE_ID']]'
Exporting dates
When exporting data from the metric/export, if the feature is set to days, you can only grab 31 days at a time. In this case, we recommend formatting your date range from the first to the last day of each month.
For example:
start_date = 2021-01-01
end_date = 2021-01-31