Skip to main content
Contributor I
Mar 5, 2024 4:56 PM UTC
Solved

Metric Aggregate Endpoint - Ordered Product by Campaign

Hello,

 

Below is my payload for https://a.klaviyo.com/api/metric-aggregates/, however I do not get the data back broken down by campaign. However the same payload works for a different metric like “Clicked Email”

{
  "data": {
    "type": "metric-aggregate",
    "attributes": {
      "metric_id": "HnmbpY",
            "measurements": ["count","unique","sum_value"],
      "interval": "day",
      "page_size": 1000,
      "timezone": "America/New_York",
            "by": ["Campaign Name"],
              "filter": [  
                  "greater-or-equal(datetime,2024-02-01)",  
                  "less-than(datetime,2024-02-29)"
              ]
    }
    }
}

 

Below are payload results:

 

Goal is to retrieve sum_value (dollar amounts) for below metrics at campaign level for given dates.

 

Thanks,

Shikha

This topic has been closed for replies.
saulblumAnswer
Klaviyo Employee
Mar 5, 2024 11:38 PM UTC

17 replies

Klaviyo Employee
Mar 19, 2024 6:48 PM UTC

Heads up, you’re showing a private API key in a screenshot, I’d suggest you delete the screenshot and remove the private key from your account.

Contributor I
Mar 19, 2024 7:08 PM UTC

Thanks, screenshot updated

Contributor I
Mar 19, 2024 7:31 PM UTC

couple more questions:

How can I get the data from API, presented in this screen shot. Placed Order by Campaign:

 

I can get Placed Order by Attributed Message, but where in UI do I see the messages tied to the campaign?

Also what does below mean? “NgAhEY” is not an attributed message id?

 

Contributor I
Mar 25, 2024 8:18 PM UTC

Hi There. Wondering if I can get response for above issues. Your help is greatly appreciated!

Brian Turcotte
Klaviyo Alum
Mar 27, 2024 4:17 PM UTC

Hi @shikha.agrawal!

My apologies for the delay here. To match the dashboards in the Klaviyo app with the API, I would recommend using our new Reporting API instead of the Query Metric Aggregates endpoint. 

 

This is because the new Reporting API endpoints pull from the same resource as the UI, so you won’t experience the discrepancy you see with the QMA endpoint. 

 

With the Reporting API, you can use the Query Campaign Values endpoint to retrieve conversion metrics:

 

Hope this helps!

Best,

Brian

Contributor I
Apr 8, 2024 4:53 PM UTC

Hi There. Thank you for your responses so far.

 

One quick question, we use private key for authentication. Will this still be supported with new API. So far it’s working, but just want to make sure private keys are not deprecating. 

 

Thanks,

Shikha

Contributor I
Apr 9, 2024 2:11 PM UTC

Hi There,

Got another question. I can get below data from API using $message attribute in metric aggregate endpoint. However I am unable to find what endpoint to use to map message id (VQkNQY) to it’s message name (WelcomeMessage). Would you please let me know how I can get this mapping?

 

Thanks,

Shikha