Solved

How to get all items in the cart

  • 15 August 2022
  • 2 replies
  • 429 views

Badge +1

We are doing a custom install of Klaviyo on our site and are having issues with multiple items in the cart.  I understand we are supposed to use a “Started Checkout” event when the first item is added to the cart.  Once that happens, a user can add a whole bunch more items into their cart.

How exactly do we get all the items in their current cart when we send our abandon emails?  I need to loop through all the items in their cart to display them but don’t see where we would store the current cart.

Thanks for the help,

 

Josh

icon

Best answer by retention 16 August 2022, 01:15

View original

2 replies

Userlevel 7
Badge +57

Hi @jlippiner, welcome to the community!

So, there’s two notions of “Cart Abandonment” that you may want to consider.  The first instance is when someone starts a Checkout (often, it leads with an email address of the visitor) and leaves without placing an order. The second instance is when someone simply “Adds to Cart” and leaves without starting the checkout process.

Considering the first scenario, this is sometimes called “Checkout Abandonment” since it’s a better descriptor of what’s happening, and is often called “Cart Abandonment” as a misnomer.  In this scenario, the user has already added one or a few items in the cart and ready to checkout.  You would send an event call to Klaviyo, with a nested array of all the items along with any other checkout details that you think would be useful.  You can look at the built-in integrations to get a sense of what Klaviyo does for the popular platforms like Shopify that you may want to consider for your custom platform:

The second instance, is a bit more tricky, as this is the actual action of “Adding to Cart” and then leaving (without yet going through the checkout process).  Now obviously, the only way to send an email to a user that never goes to the Checkout stage to enter an email address, is that this user is a previously identified (cookie/session) returning user who already subscribed previously.  Since you can’t email someone that you don’t have an email address. 

Another issues is if you have both “Checkout Abandonment” and “Add to Cart” - you wouldn’t want the user to receive both emails.  In the popular platforms, this is a custom event that you add to the platforms to capture that event “Add to Cart” - which is often superseded if there is a Checkout Started event (meaning, you get one or the other, with a higher priority on the Checkout). 

Furthermore, how do you know when someone is done adding to cart?  Is it after the first item? The second item?  Or the nth item?  The example Flow that Klaviyo provides only sends a single item, so if someone subsequently adds additional items, the Add to Cart Flow will typically send an email of only one of the items (with the others skipped because they already started a Flow).  

Having said all that, these are the conventional ways to do this because of certain complexities of the platform.  You can of course do it another way where you track an event that has all items added to a cart (in a nested array), and then you send an event to Klaviyo when their session ends (or times out).  Or you can build a Flow that checks for other “Added to Cart” since starting the Flow, so that only the last event received will trigger the Flow, so if there were multiple items, the last event (of a user session) is the one where you can loop through all the items (in the nested array).

Hope this is clear, but feel free to follow up with additional questions!

 

Badge +1

@retention thank you for the answer.  After spending the day playing with Klaviyo and the API, we have decided to move back to Drip.  Their API and UX is simply more modern and better designed for eCom if you are not using a pre-built integration.

Reply