Skip to main content
Solved

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


Forum|alt.badge.img+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.

Best answer by Brian Turcotte

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

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

Brian Turcotte
Forum|alt.badge.img+37

Hi @MoneyJ2k!
 

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

 

- Brian


Forum|alt.badge.img+5
  • Author
  • Contributor IV
  • 7 replies
  • July 17, 2023

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.


Brian Turcotte
Forum|alt.badge.img+37

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