Skip to main content

I am using the metric-aggregates API with the following request body:

{
"data": {
"type": "metric-aggregate",
"attributes": {
"measurements": [
"unique",
"sum_value",
"count"
],
"filter": [
"greater-or-equal(datetime,2024-09-18)",
"less-than(datetime,2024-10-17)"
],
"by": [
"$message"
],
"interval": "month",
"metric_id": "VDpVWX",
"page_size": 500
}
}
}

In the response, I noticed the following under the dimensions section:

"dimensions": ["RD499B"]

However, when I use the Get Campaigns endpoint:

https://a.klaviyo.com/api/campaigns/?filter=equals(messages.channel,'email')

I am unable to find a campaign with the ID RD499B. While some campaigns are listed in the response, others seem missing.

Additionally, when I modify the metric-aggregates request to include:

"by": ["$message", "Campaign Name"]

I do get the campaign name in the response.

If the Campaign Name is available through the metric-aggregates API, why doesn’t the corresponding campaign ID appear in the Get Campaigns endpoint?

Could you clarify the reason for this discrepancy?

 

Hey ​@ronen tak 

can you confirm that the Campaigns missing from the Get Campaigns endpoint are drafts, archived, or flow emails?


Hay ​@ArpitBanjara 

they are not.

 


I’ve identified what this is: it’s an event.

When I use the following endpoint:
https://a.klaviyo.com/api/events?fieldseevent]=event_properties

I can see that it’s related to a campaign.

My question is: if this is categorized as a campaign, why isn’t it accessible through the regular GET campaigns endpoint?


Answer:

The discrepancy occurs because not all campaigns or messages in the metric-aggregates API are accessible through the GET Campaigns endpoint. This behavior can arise due to:

  1. Different Data Sources:

    • The metric-aggregates API aggregates metrics from all events, including email sends, opens, and clicks, regardless of whether the message originates from a flow, campaign, or other triggers.
    • The GET Campaigns endpoint specifically returns standard campaigns, excluding certain types of messages like flow emails or archived campaigns.
  2. Event-Centric Metrics:

    • When you see a message ID (e.g., RD499B) in the metric-aggregates response, it may represent an event or flow-related message, which does not qualify as a campaign under the GET Campaigns endpoint.
  3. Campaign Name Inclusion:

    • By including "by": ["$message", "Campaign Name"] in the metric-aggregates API, you can fetch the campaign name because the message ID is still linked to historical event data.

Key Takeaway:

The metric-aggregates API provides insights into events (messages) broadly, including campaigns, flows, and other messages, while the GET Campaigns endpoint is limited to standard campaigns. To get a holistic view, consider combining event data with the Campaigns API where applicable.

If further clarification is needed, reviewing the event payload via /api/events can help pinpoint the message source and its relationship to campaigns.


@talhahussain 

thank you for your answer 

Do you know if there is an option to filter metric aggregates that only return standard campaigns?


Reply