Skip to main content
Solved

Looking for example on getting all the profiles that performed an activity on a campaign

  • February 26, 2024
  • 9 replies
  • 139 views

Forum|alt.badge.img+2

On the site when I go to https://www.klaviyo.com/metric/VGrXMr/XXXXXXX/clicked-email or https://www.klaviyo.com/metric/XXXXXXX/feed/active-on-site   (I’ve masked the metric ids here) and I get a list of all the profiles who have had the “Clicked Email” or the “Active on Site” event. 

I need to do this through the API but the only examples I have found for this type of thing are for V1 or V2. Where can I find a sample for this that uses the stable/modern API versions ?

 

 

 

Best answer by saulblum

You can call add ?include=profile to the URL and the response will have an included section that shows the properties of each profile, reference by ID returned for each event.

 

 

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

9 replies

Forum|alt.badge.img+7
  • Klaviyo Employee
  • 169 replies
  • February 26, 2024

There’s a handy comparison chart for the new API.

 

Get Events and filtering on the metric ID will get you all events for a given metric.


Forum|alt.badge.img+2
  • Author
  • Contributor IV
  • 7 replies
  • February 26, 2024

Hi Saulblum,

I appreciate your proposed solution but I have checked that comparison chart and I do not find anything for what would have been api/v1/metric/{metric_id}/profiles in the old version. :(

 


Forum|alt.badge.img+7
  • Klaviyo Employee
  • 169 replies
  • Answer
  • February 26, 2024

You can call add ?include=profile to the URL and the response will have an included section that shows the properties of each profile, reference by ID returned for each event.

 

 


Forum|alt.badge.img+2
  • Author
  • Contributor IV
  • 7 replies
  • February 26, 2024

That will do the trick! Thanks a whole bunch!  


Forum|alt.badge.img+2
  • Author
  • Contributor IV
  • 7 replies
  • February 27, 2024

Hi Saulblum,

If I look at my campaigns on the Klaviyo site, I can see the Open, Clicked and Active on site numbers on the page shown in the screenshot. 

 

I wanted to get the profile_id of people that fall under each of those events for each of the campaigns. I’ve been mostly successful thanks to your help. 

For the Open and the Clicked events, I’ve used https://a.klaviyo.com/api/events/?filter=equals(metric_id,"METRIC_ID") to get info on the "clicked-email" metric and for the "opened-email" and I was able to tie each instance to a campaign by looking at the property  attributes.event_properties.CampaignName for the campaign name and looking at attributes.event_properties.message for the CampaignId. 

 

 

However when I do the same for the metric Active on site, I can’t get the same because the CampaignName, and $message are not returned by the call to the API for that metric. Only a tiny subset  of the properties is returned as shown below.

 

Since on the first screenshot of this reply it shows the Active on Site for each campaign, I know it is feasible to the event to a campaign but how is it done for that one? 


Forum|alt.badge.img+7
  • Klaviyo Employee
  • 169 replies
  • February 28, 2024

It’s possible conversion metrics without associated monetary values, like Active on Site, are handled differently in the Get Events response.

You may be interested in the new reporting API, e.g. Query Campaign Values, that will return what you see in the UI. You can set the ID of the conversion metric, e.g. Active on Site:

 


Forum|alt.badge.img+2
  • Author
  • Contributor IV
  • 7 replies
  • February 28, 2024

I have tried it but it does not seem to work. 

in this screenshot we see that my recipients under Open rate is 4037, Click Rate is 162 and Active on Site is 44

 

Here is the body of my request posted to https://a.klaviyo.com/api/campaign-values-reports/ where there was no options for Active on site in the statistic drop-down of https://developers.klaviyo.com/en/reference/query_campaign_values so I have put its metric_id in the Conversion metric id as you suggested...

{
  "data": {
    "type": "campaign-values-report",
    "attributes": {
      "statistics": [
        "clicks_unique",
        "opens_unique"
      ],
      "timeframe": {
        "start": "2024-01-01T00:00:00",
        "end": "2024-12-31T23:59:59"
      },
      "conversion_metric_id": "METRIC_ID_FOR_ACTIVE_ON_SITE",
      "filter": "and(equals(campaign_id,\"CAMPAIGN_ID\"),contains-any(send_channel,[\"email\",\"sms\"]))"
    }
  }
}

 

Running this returns the following properties shown in the screenshot below. We can see the 162 clicks and 4037 open but nothing about the 44 Active on site. 

 

 


Forum|alt.badge.img+7
  • Klaviyo Employee
  • 169 replies
  • February 29, 2024

Does conversion_uniques work in the statistics array?


Forum|alt.badge.img+2
  • Author
  • Contributor IV
  • 7 replies
  • February 29, 2024

Yes it does. Thank you so much Saulblum. It’s a good thing that you are around to spread this knowledge as simply reading the docs by themselves do not make a clear enough on how to go about achieving this. That makes you a priceless resources! Thanks again!