Solved

Getting Event 'name' over API

  • 26 June 2023
  • 4 replies
  • 250 views

Userlevel 1
Badge +2
  • Problem Solver I
  • 7 replies

HIya - I’m using the events endpoint to pull all of a profiles events over the most recent API (v2023-06-15).

This is then endpoint I'm using: https://developers.klaviyo.com/en/reference/get_events

This works and I can retrieve events for the profile, however it looks there is not event ‘name’ in the data that's returned.

When looking at a contact’s profile within Klaviyo, it lists events by the event name, i.e.’Opened email’, ‘Started Checkout’, ‘Fulfilled Order’ etc. However when pulling the same events over the API, they’ve given an Event ID. There is no event name in the data that comes back over the API.

How can I use the events endpoint and get the event ‘name’?
alternatively, how can I get the event name if I have the event ID?

Many thanks
Stef

icon

Best answer by stem 26 June 2023, 15:25

View original

4 replies

Userlevel 2
Badge +5

you get metric_id from get_events and the name from the get_metrics endpoint

Userlevel 1
Badge +2

That’s great - thank you. 

So, first I have to make an API to get the events for a profile. 
Then I have to loop through that response making a separate API call for each event to get the event name.

Is there no way to get the events with event name in a single API call?

Thanks

Userlevel 2
Badge +5

Well, you can probably make the get metrics call once and just store the results.

I was suggesting https://developers.klaviyo.com/en/reference/get_metrics not https://developers.klaviyo.com/en/reference/get_event_metrics

Userlevel 1
Badge +2

that’s what I’ve now done 👍

First get all metrics (using getMetrics), storing event_id and event_name in associative array.

Next, get all events for a given profile and then loop through each event getting the name from my stored array.

Two API calls instead of 100!

Much better, thanks.

 

 

Reply