Overview

This guide walks through multiple ways to power abandoned cart reminders in OneSignal. You’ll learn how to sync cart data and personalize emails or push notifications when users leave items behind. You can power abandoned cart templates with:
  1. API custom_data — pass cart details inline with your message request.
  2. Tags — store key-value pairs to personalize messages.
  3. Custom Events (Early Access) — trigger Journeys from user events like cart_updated.
  4. Data Feeds — pull real-time cart data directly from your API at message send time.
Each approach supports Liquid personalization and works with both Email and Push templates.

Setup examples

Use the Create Message API with the custom_data property to inject cart data stored on your server. Best for server-side controlled cart data.Example custom_data payload:
JSON
{
  "custom_data": {
    "cart_url": "https://yourdomain.com/cart",
    "cart": [
      {
        "cartImageURL": "https://i.imgur.com/ssPCfbC.png",
        "cartProductName": "24 Pack of Acorns",
        "cartQuantity": "1",
        "cartPrice": "$12.99"
      },
      {
        "cartImageURL": "https://i.imgur.com/8QWTfV4.png",
        "cartProductName": "Fancy Sweater",
        "cartQuantity": "1",
        "cartPrice": "$9.99"
      }
    ]
  }
}

Abandoned cart email template

This email template example demonstrates how to display the cart items Using Liquid Syntax:
  • Total number of items in the cart
  • Items in the user’s cart including:
    • Product image
    • Product name
    • Product quantity
    • Product price
  • Link to the customer’s personalized cart URL

Abandoned cart email template example

Email template setup

1

Create a new email template

Navigate to Messages > Templates > New Email Template.
2

Use the Drag & Drop Editor

3

Create a 5 rows with the following:

  • Rows 1, 2, and 4 have 1 column with a Text block.
  • Row 3 has has 4 columns with: HTML block | Text block | Text block | Text block
  • Row 5 has 1 column with a Button block

Abandoned cart email template setup

Display item count in email

Using Liquid syntax, show the number of products using the size property. Within your template row 1 Text block, set your copy as desired.Example:
We're holding onto {{message.custom_data.cart.size}} items in your cart, but don't wait too long, other squirrels are getting ahead!

Display items in email

Use a Liquid for-loop to iterate over your custom_data cart array.Within template row 2 Text block, set: {% for product in message.custom_data.cart %} which starts the for-loop.Row 3 with the 4 columns will have the following in the 1st column’s HTML block:
<img src="{{product.cartImageURL}}" alt="Image" style="max-width:100%;" />
The Text blocks of the 2nd, 3rd, and 4th columns will have the text:
  • {{product.cartProductName}}
  • {{product.cartQuantity}}
  • {{product.cartPrice}}
Row 5 Text block, set: {% endfor %}The for-loop checks each product in the cart array we pass into custom_data and displays the value for each product in the columns.

Abandoned cart email template example to show items

Add a custom cart URL in email

This is optional and only needed if your carts are custom to a specific URL per customer.There are several ways to setup the cart URL. In this example we pass in the full URL to the cart within the custom_data: "cart_url": "https://yourdomain.com/cart"See Dynamic URLs for more details.In the Button block > Content Properties > Action > Url, set {{message.custom_data.cart_url}}

Abandoned cart email template example for custom URL

Finalize the email template

See Design Emails with Drag and Drop for more details on customizing the template.
When ready, you can use the template_id within your Create message API requests with custom_data property.

Abandoned Cart Push template

This push template example will demonstrate how to display an item in the user’s cart including its image and name. It also displays how many items total are in the cart and links to the customer’s personalized cart URL.

Abandoned cart push template example

Push Template Setup

Push notifications can only be sent with a limited amount of data. Instead of listing all items in the cart, we want to display the first item and mention how many total items there are.Navigate to Messages > Templates > New Push Template

Display item and item count in push

Liquid syntax provides if statements we can use to change what the message says depending on how many items in the cart array of your custom_data object.In the template Message field, add the following copy:
{% assign cart = message.custom_data.cart %}
{% assign item_count = cart.size | plus: 0 %}
{% if item_count == 1 %}
You left {{cart.first.cartProductName}} in your cart.
{% endif %}
{% if item_count == 2 %}
You left {{cart.first.cartProductName}} and {{item_count | minus: 1}} more item in your cart.
{% endif %}
{% if item_count > 2 %}
You left {{cart.first.cartProductName}} and {{item_count | minus: 1}} more items in your cart.
{% endif %}
In this example, we first assign the variable cart to be the custom_data.cart, then assign the variable item_count to be the cart.size, and, if that count is equal to 1, 2 or more than 2, display different content.Due to the cart possibly having more than 1 item, we use the first property to get the first item in the cart.We use the minus feature to reduce the total cart items count by 1 since we mention it already.

Display item image in push

In the template Image field, add the Image URL property with the liquid syntax. If the image doesn’t exist, then no image will show. You can set a default image as well. Example:
{{message.custom_data.cart.first.cartImageURL | default: "https://i.imgur.com/ssPCfbC.png"}}

Add a custom cart URL in push

In the template Launch URL field, add the cart URL property with the liquid syntax. If the cart doesn’t exist, then the push will direct to the home page of the site or app.Note on Launch URL within Templates: setting https:// or some other schema in the format x:// is required. If you set this within the data, you can use the remove feature of liquid syntax as follows:
  • https://{{message.custom_data.cart_url | remove: "https://"}}

Update the push template and send the message

See Sending Messages for more details on options provided within push templates.
When ready, you can use the template_id within your Create message API requests with custom_data property.
Need help?Chat with our Support team or email support@onesignal.comPlease include:
  • Details of the issue you’re experiencing and steps to reproduce if available
  • Your OneSignal App ID
  • The External ID or Subscription ID if applicable
  • The URL to the message you tested in the OneSignal Dashboard if applicable
  • Any relevant logs or error messages
We’re happy to help!