Solved

Accessing event data for 'track' API requests on custom website

  • 17 November 2020
  • 2 replies
  • 319 views

Badge +2

 

Hi Everyone!

I have a custom marketplace website that isn’t built on Shopify or WooCommerce (shocking, I know) and I am having some trouble accessing the information I am sending in my ‘track’ API requests (both from the front-end and the back-end).

 

Following the documentation, I have set up the ‘track’ API following the Klaviyo documentation, but I am having trouble accessing the data that I need to to set up the email flows that I want to.

 

I have included screenshots from my code showing how I am creating an object and how I’m sending that to Klaviyo. I’ve also included screenshots of what I’m seeing in Klaviyo and showing that the data I’m sending, is not available to be used as trigger conditions.

The following is a screenshot from my code where I am creating the “Items” object to be sent in the “Placed Order” event:

Object that is used as the value for the “Items” key in the next image.

The following is a screenshot from my code where I am sending the object I create to be tracked as a “Placed Order” event:

Placed Order event from the back end code​​​.

The following is a screenshot of the front end event that is fired to track a “Started Checkout” event:

Started Checkout event from the front end

The following are two screenshots from Klaviyo, showing the data being pushed by the above events:

 

The following is a screenshot of the condition dropdown in the Triggers of the email flows. As you can see, the data that I am trying to access (in “Items”) is not available to be selected from the list.

 

Any help would be greatly appreciated! The Klaviyo documentation is good for setting things up but is lacking on a lot of the support aspects once it is set up and the events are firing.

 

Thank you!!

icon

Best answer by remstone 19 November 2020, 16:12

View original

2 replies

Userlevel 2
Badge +5

hey @jakegibbons

 

Good questions - for reference: https://help.klaviyo.com/hc/en-us/articles/115005082927-Integrate-a-Custom-Ecommerce-Cart-or-Platform 

When sending in event data, you will want to make sure whatever you want to be segmentable or want it to be split in a flow to be top-level.  Based on the above documentation (screenshot below) you can see ItemNames, Categories, etc.. as top-level (top node) items inside of the event data - these will be segmentable and could be used to split a flow.  In the below, if you look at Items, its an array with objects, we can’t segment based on those nested properties

 

 

 

My recommendation is for a Placed Order and Started Checkout would be to have an ItemNames array that is top level and Categories so you can better segment!

 

Ex.

for your trackPurchaseEvent function:

let itemNames = []
for (var x in items) {
itemNames.push(items[x].item_name)
}


...
'properties': {
'$value': price,
'Items': items,
'ItemNames': itemNames
},
...

 

 

Let me know if you have questions.

Badge +2

Hi @remstone!

 

Thanks a lot for this, it’s super detailed and helpful. I was actually able to get on a call with someone at support for Klaviyo and they said the same thing so I’ve already implemented exactly what you suggested!

 

Glad your answer is consistent and is now here for other people to reference if they come across it.

 

Cheers!

 

Jake

Reply