Solved

How to get Flow Metrics from the API with Send Cohort?

  • 12 July 2023
  • 3 replies
  • 149 views

Badge +5

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.

icon

Best answer by Brian Turcotte 25 July 2023, 03:28

View original

3 replies

Userlevel 7
Badge +36

Hi @MoneyJ2k!
 

I’m going to check on this with our API team and I will update the thread as soon as possible!

 

- Brian

Badge +5

Hey @Brian Turcotte. Thanks for looking into it for me. Any word? This would be a huge help for me. We spend a ton of time running custom reports for our clients.

Userlevel 7
Badge +36

Hi @MoneyJ2k!

At this time, the best method to achieve what you’re asking is the one you referenced - using the messages API to pull the flow name, and summing the values across flow messages. However, there is a product request for the feature you’re requesting, so I will update the thread if anything changes.

 

Best,

Brian

Reply