How can we help?

Abandoned cart message


A cart event trigger initiates an automated message that targets a customer who shopped on your website, added items to their cart, and then abandoned the shopping experience.

The abandoned cart message can be delivered automatically—and in a truly personalized fashion—to promote each of the unique items that were left in the cart. This can include images of the product, links back to the cart or product page, and descriptions of the product.

You can incentivize customers with a discount, free shipping, or a call to action that rekindles their interest. The abandoned cart email, although a lower volume campaign, can yield high engagement and a great conversion rate.

Implement the trigger

In order for the abandoned cart message to send, there needs to be data sent to the system that will trigger the automation. For an abandoned cart message, we'll use the trigger of when a contact adds an item to the cart. If the item is ordered, we'll cancel the message based on an order event.

This strategy utilizes three primary pieces of data:

1. Cart attribute

  • Purpose: Used to personalize the body of the message with the actual items left in the cart.
  • Data type: An object stored as contact attribute data. The object contains an array of objects, each describing the items in the cart.

2. Cart event

  • Purpose: This named event is used to trigger the actual message sending process. It's not necessary to pass any properties along with this event because the details of the cart will be written to the cart attribute above.
  • Data type: Event data stored in the contact activities collection.

The actual name of the event is up to you, but we typically recommend "cart."

3. Order event

  • Purpose: This event will be used to cancel the message sending process if a purchase occurs during the time between the cart event and the message send (per the custom delay).
  • Data type: Event data stored in the contact activities collection.

The actual name of the event is up to you, but we typically recommend "order."

Implementation methods

There are two implementations you can use to send the data to Cordial:

1. JavaScript listener implementation: JavaScript code placed on your website that sends data to Cordial from the client-side browser.

2. Rest API implementation: A server-side alternative to JavaScript that sends data to Cordial via API.

JavaScript listener implementation

This method assumes the user's browser has a cookie that holds the necessary contact identification data. There are two ways this cookie can be set.

This article assumes you have implemented the JavaScript Listener v2. We have also included examples applicable to JavaScript Listener v1 in case you're not yet using v2.

1. A cookie will be set when a contact arrives on the site via a tracked link clicked from an email. In this case, a first-party cookie is automatically written with the necessary information to identify the contact.

2. The second way a cookie may be set is by calling a basic identification function in JavaScript. When a customer logs into a site/store or provides their email address via form submission (ex: newsletter sign-up form), a function may be called to pass the email address to Cordial. The crdl(contact) method can set the cookie and add or update a contact record.

  • crdl('contact', auth_data, contact_data);
  • In JS listener v1, the cordial.identify sets the cookie and the adds or updates the contact record.


When a cart is updated, run the following functions:

  • crdl([
        ['cart', 'clear'],
        ['cartitem', 'action' , cart_data], 
        ['event', 'cart']
  • cordial.event('cart');
    cordial.cartitem('action',[array of cartitemObjects]);

There are two possible actions for the crdl(cartitem) method:

  • add: add a new cart item record or increment the quantity of an existing record.
  • remove: remove an existing cart item (supports a single object of cartitems).

You can find full details on working with a single or array of cart items here.

Best practice for managing the cart state: Although we do support the ability to add or remove individual items to the cart object, most implementations simplify management of the cart state by calling ['cart', 'clear'] and then ['cartitem', 'add' , cart_data] on each cart event, effectively clearing and repopulating the entire cart object. This assumes the front end has access to all the items in a given cart.

When an order is placed (checkout), run the following functions:

  • crdl([
        ['cart', 'clear'],
        ['order', 'action' , order_data], 
        ['event', 'order']
  • cordial.clearcart();

The ['event', 'order'] call is optional and not required for cart abandonment. However, we highly recommended that order data is passed using either this method or the REST API to take advantage of segmentation by purchase behavior.

REST API implementation (server-side alternative to JavaScript)

This method assumes the contact has been identified as part of the session.

The REST API implementation is an alternative method to the embedded JavaScript Listener. This is a server-side approach to sending the same data.

Methods to call when a cart is updated:

Methods to call when a purchase occurs:

Create an automated message

Now that you have the appropriate data points (passed by either the JavaScript Listener or REST API), you can can set up the event-triggered automation template.

1. Log in to Cordial and navigate to Message Automation > Create New Automation.

2. Provide the necessary information and click Continue.

3. Under the Sending Methods panel on the left, click Event Triggered.

4. For Trigger event, choose Custom event and select cart.

The cart option will appear in this menu as soon as the first event has been passed to the account.

5. For Delivery time choose Delay sending. Set the Delay to an interval that makes sense for your shopping experience.

6. For Handling events triggered during delay, there are a series of conditions that can be set.

  • First condition: If cart Then select Restart delay time. This ensures the full delay is respected if other cart events occur after the initial event.
  • Add a second condition: If order Then select Cancel sending. This ensures that the cart abandonment email is not sent if the customer completes the order before the delay time ends.

7. For How often can this message be sent to an individual select Custom interval and set the frequency limit to an interval that makes sense for the shopping experience.

We recommend limiting these triggers to a once a week.

8. Save the trigger setting.  

9. Once you've saved the trigger and published the message content, you can Enable the message. As soon as the message is enabled, the triggers are active and will send the message according to the rules applied.

Code the message content

The following is a very simple example of the Smarty script for printing the cart items in the body of the message. Apply markup and styling according to your brand or style guide.

You left the following items in your cart:<br> 

{foreach $contact.cart.cartitems as $item}
<b><a href="{$item.url}">{$}</a></b><br>
SKU: {$item.sku}<br/> Description: {$item.description}<br>
Qty: {$item.qty}<br/> Price: {$item.amount}<br><br>
<a href="{$item.url}"><img src="{$item.images.0}" /></a><br>

Once your draft is tested and ready to be published, publish the content, set the headers, and enable the trigger sending method. Your abandoned cart email will be enabled and active.

In the next article, you can learn how to set up an order confirmation message.



Article is closed for comments.