Skip to main content
Solved

Is there a way to see if a profile has an event with a specific property via the API

  • February 8, 2022
  • 3 replies
  • 374 views

Forum|alt.badge.img+2

Hi, How’’s everyone doing?

I was wondering if there’s any way to check if a profile has an event attached to them with a specific property set, via the api.

For example

Profile ID: xxxx
Metric_ID: xxxx
Property: { Product_id: 114 }

Ultimately I’m trying to query the API to check if a customer has purchased a product. (BigCommerce doesn’t have this functionality, which seems insane).

Thanks, Toby

Best answer by alex.hong

Hi @Tobear,

Thanks for your follow up and other questions. You are on the right track with the timeline endpoint callout. “https://a.klaviyo.com/api/v1/metric/(metric_ID)/timeline?count=XXX&sort=desc&api_key=XXX.” That will yield all of the information about people for a certain metric that you can then sort by any property pulled (example:ID of the person, email address, event data pertaining to the event, etc.). I am not sure what you mean by “this one doesn’t provide a way to filter the events by a property within it.” Could you clarify?

I would use that call to pull all event data and profile info and then follow up with errors afterwards. 

 

Thank you!
Alex

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

3 replies

alex.hong
Forum|alt.badge.img+58
  • Klaviyo Alum
  • 1552 replies
  • February 8, 2022

Hi there @Tobear,

Hope you’re having a good day! I will do my best to provide some info regarding your question.

If you’re just looking to check Profile Properties for Klaviyo, you could try use the identify endpoint. Any timestamped action (like when somebody places an order or starts a checkout) would be what the track endpoint is for.

Since Klaviyo has a schema-less database (noSQL), you don’t have to pre-define the custom properties inside Klaviyo before you send those API requests. So you could start right away by sending your CRM data to Klaviyo via the identify endpoint as soon as you’d like. An example payload might look like this:

{
    "token": "ABC123",
    "properties": {
      "$email": "connor.test@klaviyo.com",
      "$first_name": "Connor",
      "$last_name": "B",
      "Total Number of Purchases": 3,
      "Loyalty Points": 200,
      "Language Preference": "EN" 
    }
}

The identify endpoint was designed for very high throughput and low latency, and is an asynchronous endpoint. Because of this, we don’t have a way to bulk-upload this data, but you can essentially make API requests as fast as you’d like and you will almost certainly not hit any rate limits. 

 

Feel free to check out our dev documentation too! I believe you’ll find the info you are looking for there as well!

 

All the best,

Alex


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 2 replies
  • February 9, 2022

Hi, @alex.hong 

Thanks for the reply.

Am I wrong in assuming that the identify & track endpoints are only to push data to Klaviyo?

I’m looking for a method to query the data after it’s been pushed. In my case to verify a profile has a product_purchase event with a specified product id.

The equivalent in the Klaviyo dashboard would be the profile charts with a filter. (I’d need the same information but through the api).

The closest I’ve come is with the metric/{metric_id}/export endpoint however this queries all profiles
which isn’t what I need.

The second method was to use the person/{person_id}/metric/{metric_id}/timeline endpoint, however this one doesn’t provide a way to filter the events by a property within it.

Any help would be greatly appreciated.

Thanks, Toby


alex.hong
Forum|alt.badge.img+58
  • Klaviyo Alum
  • 1552 replies
  • Answer
  • February 9, 2022

Hi @Tobear,

Thanks for your follow up and other questions. You are on the right track with the timeline endpoint callout. “https://a.klaviyo.com/api/v1/metric/(metric_ID)/timeline?count=XXX&sort=desc&api_key=XXX.” That will yield all of the information about people for a certain metric that you can then sort by any property pulled (example:ID of the person, email address, event data pertaining to the event, etc.). I am not sure what you mean by “this one doesn’t provide a way to filter the events by a property within it.” Could you clarify?

I would use that call to pull all event data and profile info and then follow up with errors afterwards. 

 

Thank you!
Alex