Abandoned cart message – Cordial Knowledge Base

How can we help?

Overview

With an abandoned cart message, 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.

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

How it works

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.

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 their cart. If the item is ordered, we'll cancel the message based on an order event.

This strategy utilizes three primary pieces of data:

Cart attribute

Cart event

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

Order event

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

Sending methods

There are two ways to send this data to Cordial:

  1. JavaScript Listener: JavaScript code placed on your website that sends data to Cordial from the client-side browser.
  1. Rest API: A server-side alternative to JavaScript that sends data to Cordial via API.

JavaScript Listener method

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 can be set is by calling a basic identification function in JavaScript. When a customer logs in to a site/store or provides their email address via form submission (e.g., newsletter sign-up form), a function can 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 `cordial.contact` adds or updates the contact record.
cordial.identify(emailaddress);
cordial.contact();
```

When a cart is updated, run the following functions:

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

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

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();
cordial.order('action',orderObject);
cordial.event('order');
```

The ['event', 'order'] call is optional and not required for cart abandonment. However, we highly recommend 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 message content

You can create a Sculpt Template and Blocks with dynamic content that will populate based on the abandoned item.

Create the automation

Once you have the appropriate data points (passed by either the JavaScript Listener or REST API) and the content of your message, you can set up the event-triggered automation.

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

  2. Provide the necessary information and click Continue.

  3. If using Sculpt, select the desired Template under Message Content.

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

  5. For Trigger event, choose A contact's real-time behavior and select cart.

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

  1. For delivery time, set the Delay to an interval that makes sense for your shopping experience.

  2. For Handling events triggered during delay, there are a series of conditions you can set.

  1. 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.

  1. Click to Save the trigger setting.

  2. Once you've saved the trigger and published the message content, you can click the Enable button. 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}">{$item.name}</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>
    {/foreach}
    ```

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](https://support.cordial.com/hc/en-us/articles/115005532688).