Skip to main content

I use this body to fetch 

Clicks Email_unique,
Opened Email_unique
{
"data": {
"type": "metric-aggregate",
"attributes": {
"measurements":
"unique",
"sum_value",
"count"
],
"filter":
"greater-or-equal(datetime,2024-08-01)",
"less-than(datetime,2024-08-31)"
],
"by":
"$message"
],
"interval": "month",
"metric_id": "VRABRR",
"page_size": 500

}
}
}
 

I use $messages to get them by campaign id
And I got numbers that are far from what I see in the user interface

For example, in the UI, I got

Unique Opens = 306840, Unique Clicks = 1823

and in the API, I got

Unique Opens = 61956, Unique Clicks = 595

Why is the gap so high? This is not negligible at all.

So, I read what you wrote in your guide here 

As you're aware, there is a daily rate limit in place. I quickly hit this limit when I use a loop to fetch data across all my metrics and adjust the date range. Please consider increasing the rate limit to something more manageable or adjusting the aggregation to return the same data as the UI.


@ronen tak, here we explain the reason for the discrepancy between the query metric aggregates endpoint & the UI in our guide here (https://developers.klaviyo.com/en/docs/using_the_query_metric_aggregates_endpoint#about-metric-aggregates-and-klaviyo-reporting)

 

For flows, you’re able to use the series endpoint (https://developers.klaviyo.com/en/reference/query_flow_series) to get data. This may help to lower the number of requests you need to make to get data across different time ranges.

For both campaigns + flows, we recommend persisting the values you query from previous days vs. needing to re-query for historic date ranges every day. 


@Kim Strauch 

Thank you for your reply.

However, the issue still needs to be resolved. Even though I persist with the queried values, querying data for an entire day still takes 10 minutes for 20 metrics (with a limit of only two requests per minute).

You should consider increasing the limit to something more reasonable.

Please correct me if I’m wrong.


Reply