Skip to main content

Hi Team,

 

Looking at the following documentation:

https://developers.klaviyo.com/en/docs/using_the_query_metric_aggregates_endpoint#unique-opens-unique_opens-for-all-sent-messages

The  Metric Aggregates API is used with a GROUP BY `$message`. According to the documentation:

 

> The results will be grouped by message ID (using "by": ["$message"] as an attribute).

 

However, when doing some local tests using my own data, it seems to be that the campaign ID is returned, and not the message ID. This means, either the document is wrong, or the API response is wrong.

 

Would it be possible to get some clarity on this? Knowing which ID is being returned is crucial in our data pipelines.

 

All the best,

Louis
 

Hi ​@Larry,

Just reached out to our team that writes these API docs. I’ll get back to you as soon as possible with more information on this article, and to let you know what the source of truth here should be.


Back with an update! 

For legacy campaigns (not the new Omnichannel campaigns feature), $message will give the campaign id  depending on send channel and A/B test state.

  • Email and push will always populate the EmailCampaign id in the $message field
  • SMS will populate the EmailCampaign id there if it's an A/B test
  • SMS will populate the ScheduledMessage id if it isn't an A/B test

For Omnichannel campaigns, all channels will now use the following:

  • $message will be populated by the OmniMessage Id

For these reasons, we recommend using the Query Campaign Values endpoint when you’re trying to gather campaign data like this. Let me know if this helps.