Skip to main content
Problem Solver I
June 3, 2024
Solved

how i can retrive campaign id by using aggregate

  • June 3, 2024
  • 12 replies
  • 308 views

I try to obtain the data with a breakdown by date

and I want to get the campaign ID to

for now, I succeeded received by campaign name, but this is not good enough because I need the campaign ID value that should be single-valued that I can use after that with join to other tables

this the code that I use for now

 
const metric = 'xyz'
const body = {data: {
type: 'metric-aggregate',
attributes: {
measurements: ['count'],
filter: [
`greater-or-equal(datetime,${'2024-06-01'})`,
`less-than(datetime,${'2024-06-03'})`,
],
interval: 'day',
metric_id: metric,
timezone: 'UTC',
},
},
};

 

    This topic has been closed for replies.
    Best answer by saulblum

    Go to the metrics page in the UI, e.g. Placed Order, and the six-character ID will be in the URL. Specific events of a metric, e.g. a specific profile who has a Placed Order event, may be attributed to a campaign or flow, per https://help.klaviyo.com/hc/en-us/articles/1260804504250

    12 replies

    ronen takAuthor
    Problem Solver I
    June 27, 2024

    Regarding your question about my preferences, it's primarily for convenience. Below is an image illustrating how I envision it, with the division by days being particularly useful

     

    Kim Strauch
    Klaviyo Employee
    Klaviyo Employee
    June 27, 2024

    @ronen tak, thanks for sharing this view. This is helpful!

    You could create an output like this for campaigns using the reporting API, where you also call GET /api/campaigns to get the date the campaign was sent to create such a view, for example if you want to know when the campaign was sent and all the stats associated with that campaign in aggregate, vs. having multiple rows per campaign based on the dates users engaged. I suppose it’s a matter of personal preference