In this document, we are going to show you how to track abandoned shopping carts as custom events, which can then be used to trigger automated notifications to recover them.
These steps are for non-Shopify websites. If you are using Shopify, then Abandoned Carts are automatically tracked for you as an event and you do not need to follow these steps below. Simply head to your dashboard and activate abandoned cart notifications under "Notifications" > "Triggered Notifications".
Step 1: Abandoned Cart Listener Snippet
The first step is to add the following snippet on your "Cart" or "Checkout" page. Place this just below your closing "</body>" tag.
In this example, a cart is deemed abandoned if the user does not complete it in 30 minutes. You can change that to any number you want (60 = 60 minutes, 120 = 2 hours, etc)
Step 2: Cart Completion Listener
Next, place the following code on your "order complete" or "thank you" page.
Step 3: Create Triggered Campaign
After you add those you will start seeing "Abandoned Cart" events start showing up in your event logs and you can create the triggered campaign to send notifications those who trigger it. It's usually easiest to let the code run for 24 hours so that you can easily see the events being logged in your dashboard ("Logs" > "Event Logs"). Once you are ready you may proceed to adding custom event triggered notifications.