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
how can I know which metric is attributed to a campaign?
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
I am upgrading my apex code in salesforce for the new version of Klaviyo Api. But when I am trying to run the code authorisation is failing for some reasons. When I use this syntax: req.setHeader('Authorization', 'Klaviyo-API-Key “My Api Key Hardcoded”');,
I am getting the response but i dont want hardcoded value to give here. while trying this syntax i am getting the error 400 :
Can someone please give me a solution to this.Its urgent.
I am upgrading my apex code in salesforce for the new version of Klaviyo Api. But when I am trying to run the code authorisation is failing for some reasons. When I use this syntax: req.setHeader('Authorization', 'Klaviyo-API-Key “My Api Key Hardcoded”');,
I am getting the response but i dont want hardcoded value to give here. while trying this syntax i am getting the error 400 :
Can someone please give me a solution to this.Its urgent.
@coder, if you’re getting a 401 error, that’d indicate you have an issue in how you’re sending the authorization/private key information. If you’re getting a 400 error that likely indicates an issue with how you’re formatting the request body. Do you mind starting a separate post with more details on your request so we can help out? Thanks!
Otherwise, if you’re specifically trying to get placed orders or other metrics aggregated / attributed to various campaigns in a timeframe, you can use the approach @saulblum described above. Using the “by: $attributed_message” group by should group by the relevant campaign ID or flow message ID. If you want to filter out flows, you might do a query like the following
@ronen tak so in the case of clicked/opened/received email/sms metrics for this endpoint, you’ll want to use "by": b"$message"]
$attributed_message is what you’d want to use in the case of trying to get Placed Order, Active on Site, Added to Cart, events that are attributed to this campaign.
If you update your API call above to use $message, you should see campaign IDs under “dimensions”.
Given the complexity involved with this endpoint, I’d recommend the Query Campaign Valuesendpoint instead. To get opens, unique opens and open rate, you’d do something like
POST https://a.klaviyo.com/api/campaign-values-reports/
When you do this, you’ll get a response back where each result is grouped by campaign and will say “campaign_id” so you can clearly see which campaign these opens are associated with.
How can I identify which metrics are related to the campaign ID and which are not?
This endpoint does not return data broken down by date as the aggregate endpoint does. Therefore, it does not meet my needs.
@ronen tak, 1. I’m not sure what you mean by “How can I identify which metrics are related to the campaign ID and which are not?”. Do you mean, when should you use $message vs. $attributed_message? If so, for things like email opened/clicked/received/etc. (klaviyo-sourced metrics related to message sending), you should use $message, and for anything else you want to understand that might be attributed to the campaign (e.g. active on site, placed order, etc.) you should use $attributed_message. Hopefully that answers your question.
2. Can you share more details on why you want the data broken out (e.g. for clicks) on a day-by-day basis? I understand this use case for flows which are sent to users at all kinds of different times but would be curious to learn more about your use case for this for campaigns
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
@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