A few months ago I asked about why the Klaviyo Custom Reports don’t match the metrics found in the API. I was told this is because the API does not include send cohort.
This seems to have changed. There are now two new attributes
- "$message_send_cohort"
- "$variation_send_cohort"
Both of these seem to work very well. The data I get matches the exports perfectly for campaigns. That is fantastic, thank you to whoever added this.
One problem, however, this only responds with messages. So it works great for campaigns, but instead of returning flows, it returns, each individual message in each flow. This is obviously a problem if you are trying to get accurate metrics by flow by date. This is my API request
"data": {
"type": "metric-aggregate",
"attributes": {
"metric_id": metric_id,
"interval": interval,
"page_size": page_size,
"timezone": "UTC",
"measurements": [measurement],
"filter": [
"greater-or-equal(datetime,2022-07-11T00:00:00)",
"less-than(datetime,2023-07-11T00:00:00)",
],
"by": ["$message_send_cohort"],
},
}
}
headers = {
"accept": "application/json",
"revision": "2023-02-22",
"content-type": "application/json",
"Authorization": f"Klaviyo-API-Key {api_key}",
}
I see two possible solutions to this, either 1, I am simply using the wrong attribute and there is a way to get by flow data with send_cohort, or, there is a way to get the flow name, from a message ID. I am thinking I could look up each message ID and get the flow name that way, I just think that would end up being a ton of API requests.
Any thoughts appreciated. The end goal is just to have accurate metric/conversion data that is attributed to flows. using send cohort.