# Automated Abandoned Cart

An Abandoned Cart campaign targets users who added an item to their cart but did not complete their purchase. A few timely reminders can provide effective motivation for your customers to revisit their carts and check out.

Abandoned Cart messages send when specific user behaviors occur. A developer must [set up your app with events](#setting-up-events-in-the-app) for those behaviors, but anyone with access to create messages in the Airship dashboard can [get started now](#setting-up-the-automation).

> **Tip:** With the use of Abandoned Cart messaging in the Airship platform, [JCPenney saw a 40% lift in purchase completion rates and Radisson Hotels saw a 11% lift in completed reservations](https://salestechstar.com/sales-engagement/airship-journeys-powers-massive-conversion-gains-for-brands-across-the-globe/).


## Setting up events in the app

A developer must set up [Custom Events](https://www.airship.com/docs/reference/glossary/#custom_event) in your app or website so they can be used for automation:

| Event Name | Description |
| --- | --- |
| added_to_cart | An item is added to the cart |
| purchased | A user makes a purchase |
| empty_cart | The last or only item is removed from the cart |

Setting up events to send to Airship can be done in the iOS, Android, and Web SDKs with the following calls. Use the below templates to create the events. See also [Custom Event Templates](https://www.airship.com/docs/sdk-topics/custom-events/).

> **Note:** If you use an [integration](https://www.airship.com/docs/integrations/) or your application is already instrumented with Custom Events, you may need to adjust the event names for `purchased` and `added_to_cart`.


Add an event for when a item is added to cart:


#### Android


```java
RetailEventTemplate.newAddedToCartTemplate().createEvent().track();
```



#### iOS Swift


```swift
let retailTemplate = UARetailEventTemplate.addedToCart()
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
```




#### Web


```js
new sdk.CustomEvent.templates.retail.AddedToCartEvent().track()
```




Add an event for when the cart is purchased:


#### Android


```java
RetailEventTemplate.newPurchasedTemplate().createEvent().track();
```



#### iOS Swift


```swift
let retailTemplate = UARetailEventTemplate.purchased()
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
```



#### Web


```js
new sdk.CustomEvent.templates.retail.PurchasedEvent().track()
```




And an event for when the last or only item is removed from a cart:


#### Android


```java
CustomEvent.newBuilder("empty_cart")
        .build()
        .track()
```



#### iOS Swift


```swift
let event = CustomEvent(name: "empty_cart")
event.track()
```



#### Web


```js
var event = new sdk.CustomEvent("empty_cart")
event.track()
```




## Setting up the automation

You will create a [Sequence](https://www.airship.com/docs/reference/glossary/#sequence) that contains your message and settings for each event. You can set up a Sequence now, even if the events don't yet exist in your app. Once the app is ready, make the Sequence active. In fact, you can enter whatever events you'd like, but be sure to edit the Sequence for the correct events before making it active.

If you're creating the Sequence as a test and don't intend to make it active, you may want to include "Do not start" or similar in the Sequence name as a notice to your team members.

You will configure these Sequence components:

| Component | Associated Event | Description |
| --- | --- | --- |
| **Trigger** | added_to_cart | Users enter the Sequence when this event occurs. |
| **Message** | n/a | Airship sends the message to users who enter the Sequence. |
| **Conversion event** | purchased | Users exit the Sequence when this event occurs. This prevents sending the Abandoned Cart message to a user if they make a purchase. |
| **Cancellation event** | empty_cart | Users exit the Sequence when this event occurs. This prevents sending the Abandoned Cart message to a user if they no longer have any items in their cart. |

> **Tip:** Conversion and cancellation events have the same effect on a Sequence. The different classifications are for reporting and mapping.


### New Sequence

![Creating a new Sequence by selecting Start from scratch](https://www.airship.com/docs/images/use-cases/abandoned-cart/seq-1_hu_7e578862ca39c4ce.webp)

*Creating a new Sequence by selecting Start from scratch*

To get started, create a new Sequence and give it a name:

1. In the sidebar, select the **Create** dropdown menu (
), then select **Sequence**, then **Start from scratch**.
1. Name the Sequence "Abandoned Cart".
1. Select **Continue**.

You will now be in the [Journey Map](https://www.airship.com/docs/reference/glossary/#journey_map), where will you configure the three events.

### Trigger

![Configuring the added_to_cart event](https://www.airship.com/docs/images/use-cases/abandoned-cart/seq-2_hu_10989f5e3eee2a22.webp)

*Configuring the added_to_cart event*

Configure the event that will cause users to enter the Sequence:

1. Select the trigger card in the Journey map, then select the edit icon (
).
1. Select **Custom Event**.
1. Enter "added_to_cart".
1. Select **Save**.

### Conversion event

![Configuring the purchased event](https://www.airship.com/docs/images/use-cases/abandoned-cart/seq-3_hu_1a37c8d671fadbb.webp)

*Configuring the purchased event*

Configure the event that will cause users to exit the Sequence when they purchase an item:

1. Select the Sequence card in the Journey map, then select the plus icon () to its right.
1. Select **Conversion Event**, then **Custom Event**.
1. Enter "purchased".
1. Select **Save**.

### Cancellation event

![Configuring the empty_cart event](https://www.airship.com/docs/images/use-cases/abandoned-cart/seq-4_hu_b79ecbffa9fc08f.webp)

*Configuring the empty_cart event*

Configure the event that will cause users to exit the Sequence if they no longer have anything in their carts to purchase:

1. Select the Sequence card in the Journey map, then select the plus icon () to its right.
1. Select **Cancellation Event**, then **Custom Event**.
1. Enter "empty_cart".
1. Select **Save**.

### Your message

While it's possible to set up multiple messages in a Sequence, our example is for a single message. See [Create a Sequence](https://www.airship.com/docs/guides/messaging/messages/sequences/create/create/) for full documentation.

---

![Changing the message delay](https://www.airship.com/docs/images/use-cases/abandoned-cart/seq-5_hu_28f06673d4556167.webp)

*Changing the message delay*

First, set the Message Delay — the time Airship should wait after receiving the triggering event before sending your message. For our example, set it to send one day after the most recent `added_to_cart` event has occurred:

1. Select the Sequence card in the Journey map, then select the compose icon (
). You will now be in the [Sequence Manager](https://www.airship.com/docs/reference/glossary/#sequence_manager).
1. Select the arrow icon (
) next to **Conditions** to close that page section.
1. Under **Message Delay**, select the default value **1 hour** and change it to one day.
1. Select **Save**.

---

Now you can select the audience and define the message to send:

1. Select **Add message content**.
1. In Setup, select [Originating Channel](https://www.airship.com/docs/reference/glossary/#originating_channel) and the channel you set up your Abandoned Cart events for.
1. In Content, select **Push Notification**, then **Add Content**. In the **Text** field, enter a message that tells the customer that they have items remaining in their cart.
1. In Review, verify what your message will look like on an actual device:
   1. Select **Send Test**.
   1. Under **Test audience**, enter at least one [Named User](https://www.airship.com/docs/reference/glossary/#named_user) or [Test Group](https://www.airship.com/docs/reference/glossary/#preview_test_groups) and select from the results. If your message includes email, you can also search for email addresses. If no matches appear for an address, you can select **Create channel for &lt;address&gt;**, and the channel will be registered for your project and opted in to transactional messaging. Users in an active [Holdout Experiment](https://www.airship.com/docs/reference/glossary/#holdout_experiment) will not receive a test message. You can view a user's current holdout group status and history when [viewing their channel details in Contact Management](https://www.airship.com/docs/guides/audience/contact-management/#viewing-channel-details).
   1. (If your message contains [Handlebars](https://www.airship.com/docs/reference/glossary/#handlebars)) Under **Personalization**, select and configure a personalization data source:

      | Data source | Description | Steps |
      | --- | --- | --- |
      | **Test message recipient** | The message will be personalized using information associated with each test audience member. | n/a |
      | **Preview Data tool** | The message will be personalized using the data currently entered in the [Preview Data tool](https://www.airship.com/docs/guides/personalization/previewing/). The same values will apply to all test message recipients. You can also manually edit the JSON. | (Optional) Edit the JSON data. |
   1. Select **Send**.

   The push should appear on test user devices momentarily.
   
1. Select **Save and continue**, and you'll be back in the Manage screen.

After you confirm the Sequence is working as expected and events are sending for your customers, select **
 Start** on the Manage screen to make it available to your audience.

## Next steps

Take your messaging further:

<!--- Restore later

* **Customize it** — You just learned how to make a basic version, but the most successful Abandoned Cart messaging is personalized for the user. Go to [Customized Abandoned Cart]() to learn how.

-->

* **Measure performance** — After making a Sequence active, you'll want to know how users respond to your messaging. See [Performance Report](https://www.airship.com/docs/reference/glossary/#sequence_performance).

* **Learn about A/B testing** — Use A/B testing to determine which version of a message has the best impact on your Sequence. See [Sequence A/B Tests](https://www.airship.com/docs/guides/experimentation/a-b-tests/sequences/).

* **Personalize it** — The most successful Abandoned Cart messaging is personalized for the user. See [Personalization](https://www.airship.com/docs/guides/personalization/about/).

* **Learn about Sequence testing** — Since our example was for a single message, the steps above had you send a test for the message itself. We also have a Test Run feature that tests the full Sequence so you can ensure the messages are built correctly as they are delivered to your test devices. Test Runs include a report identical to the [Performance Report](https://www.airship.com/docs/reference/glossary/#sequence_performance), but the data is based on your test audience.

   Learn about all Sequence testing options in [Test a Sequence](https://www.airship.com/docs/guides/messaging/messages/sequences/create/test/).