Skip to main content
Solved

Query Metric Aggregate API returning not returning campaign-id for SMS Campaigns

  • January 23, 2025
  • 1 reply
  • 25 views

Forum|alt.badge.img+2

When using the Query Metric Aggregates API for fetching the “Placed Order Metrics”, we are getting “campaign-id” as dimension for the “Email Campaigns”, and “campaign-message-id” as the dimension for the “SMS Campaigns”.

This is blocking us from using the API output correctly.

 

As per another community ticket, the intended behaviour is that the dimensions are “campaign-ids”.  We’re seeing a different behaviour from the Klaviyo APIs now.

 

Here is the payload we’re using for fetching the data:

{
	"data": {
		"type": "metric-aggregate",
		"attributes": {
			"metric_id": "<PLACED_ORDER_METRIC>",
			"measurements": [
				"count"
			],
            "filter":[
                "greater-or-equal(datetime,2024-10-01T00:00:00)"
                , "less-than(datetime,2025-01-24T00:00:00)"
                , "not(equals($attributed_message,\"\"))" 
            ],
			"interval": "month",
			"page_size": 500,
			"by": [
				"$attributed_message"
			],
			"timezone": "UTC"
		}
	}
}

 

 

@Brian Turcotte ​@chloe.strange 

Best answer by MANSIR2094

Hello ​@vaibhavrai2446 ,

The issue you're encountering with the Query Metric Aggregates API likely stems from inconsistencies in how Klaviyo dimensions are structured for email and SMS campaigns. Ideally, both should use "campaign-ids" for consistency. To address this:

1. Double-check Klaviyo's API documentation for any recent updates regarding dimension behavior for "Placed Order Metrics."

2. If the issue persists, try a workaround by normalizing the output dimensions in your data pipeline to handle both "campaign-id" and "campaign-message-id."

3. Contact Klaviyo support or your Klaviyo account manager to confirm if this behavior is intentional or a bug.

 

If this seems complex, feel free to reach out, and I can assist with implementing a robust solution.

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

1 reply

MANSIR2094
Problem Solver IV
Forum|alt.badge.img+13
  • Problem Solver IV
  • 174 replies
  • Answer
  • January 23, 2025

Hello ​@vaibhavrai2446 ,

The issue you're encountering with the Query Metric Aggregates API likely stems from inconsistencies in how Klaviyo dimensions are structured for email and SMS campaigns. Ideally, both should use "campaign-ids" for consistency. To address this:

1. Double-check Klaviyo's API documentation for any recent updates regarding dimension behavior for "Placed Order Metrics."

2. If the issue persists, try a workaround by normalizing the output dimensions in your data pipeline to handle both "campaign-id" and "campaign-message-id."

3. Contact Klaviyo support or your Klaviyo account manager to confirm if this behavior is intentional or a bug.

 

If this seems complex, feel free to reach out, and I can assist with implementing a robust solution.