Skip to main content
Contributor I
March 5, 2024
Solved

Metric Aggregate Endpoint - Ordered Product by Campaign

  • March 5, 2024
  • 17 replies
  • 274 views

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.

17 replies

Klaviyo Employee
March 19, 2024

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
March 19, 2024

Thanks, screenshot updated

Contributor I
March 19, 2024

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
March 25, 2024

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

Brian Turcotte
Klaviyo Alum
March 27, 2024

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
April 8, 2024

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
April 9, 2024

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