Overview

If you’re tracking users’ abandoned carts on your server or want to implement reminders using OneSignal, this guide explains how to structure and send personalized messages via email or push notifications. You can either:

  • Use the custom_data API parameter to pass structured data from your server, or
  • Leverage Data Tags and Journeys for scalable message automation within OneSignal.

Option 1: Using custom_data

Use our Create message API with the custom_data property to send cart data stored on your server. This is ideal for server-side data and enables full personalization.

Example custom_data payload:

{
  "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"
        },
        {
            "cartImageURL": "https://i.imgur.com/ZI6XrpC.png",
            "cartProductName": "Squirrel Hammock",
            "cartQuantity": "1",
            "cartPrice": "$14.59"
        },
        {
            "cartImageURL": "https://i.imgur.com/VDOnWKB.png",
            "cartProductName": "Acorn Catapult Shirt",
            "cartQuantity": "1",
            "cartPrice": "$5.89"
        }
    ]
  }
}

Option 2: Data tags

Tags allow you to store and reference simple key: value pairs for personalization. Since arrays and objects aren’t supported, you’ll typically store only the last item added and how many total items in the cart. Example:

{
  "cartImageURL": "https://i.imgur.com/ssPCfbC.png",
  "cartProductName": "24 Pack of Acorns",
  "cartQuantity": "1",
  "cartPrice": "$12.99",
  "cartItemsCount": "4",
  "cart_url": "https://yourdomain.com/cart"
}

Abandoned cart email template

This email template example will demonstrate how to display the following 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:

  • Custom Data: use the size property. Example: {{ message.custom_data.[key].size }}.
  • Data Tags: use the cartItemsCount tag. Example: {{ cartItemsCount }}.

Within our 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!

We're holding onto {{ cartItemsCount }} items in your cart, but don't wait too long, other squirrels are getting ahead!

Display items in email

  • Custom Data: Use a Liquid for-loop to iterate over your custom_data cart array.
  • Data Tags: Only the most recent item will be shown based on your tag structure.

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.

If using Data Tags, you can remove the rows with the for-loop. Remember to change the liquid syntax based on your tag structure.

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 or tag like this: "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}} if using custom_data
  • {{cart_url}} if using tags

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.

For tags, you can send using any methods.


Abandoned Cart Push Setup

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 or cartItemsCount tag.

In the template Message field, add the following copy:

{% assign item_count = message.custom_data.cart.size | plus: 0 %}
{% if item_count == 1 %}
You left {{message.custom_data.cart.first.cartProductName}} in your cart.
{% endif %}
{% if item_count == 2 %}
You left {{message.custom_data.cart.first.cartProductName}} and {{item_count | minus: 1}} more item in your cart.
{% endif %}
{% if item_count > 2 %}
You left {{message.custom_data.cart.first.cartProductName}} and {{item_count | minus: 1}} more items in your cart.
{% endif %}

In this example, we assign the variable item_count to be the custom_data.cart.size or the tag cartItemsCount and if that count is equal to 1, 2 or more than 2, display different content.

Due to the cart may 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"}}
  • {{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 tag, you can use the remove feature of liquid syntax as follows:

  • https://{{message.custom_data.cart_url | remove: "https://"}}
  • https://{{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.

If using tags, you can send using any of OneSignal’s options for Sending Messages.

Need help?

Chat with our Support team or email support@onesignal.com

Please 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!


Overview

If you’re tracking users’ abandoned carts on your server or want to implement reminders using OneSignal, this guide explains how to structure and send personalized messages via email or push notifications. You can either:

  • Use the custom_data API parameter to pass structured data from your server, or
  • Leverage Data Tags and Journeys for scalable message automation within OneSignal.

Option 1: Using custom_data

Use our Create message API with the custom_data property to send cart data stored on your server. This is ideal for server-side data and enables full personalization.

Example custom_data payload:

{
  "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"
        },
        {
            "cartImageURL": "https://i.imgur.com/ZI6XrpC.png",
            "cartProductName": "Squirrel Hammock",
            "cartQuantity": "1",
            "cartPrice": "$14.59"
        },
        {
            "cartImageURL": "https://i.imgur.com/VDOnWKB.png",
            "cartProductName": "Acorn Catapult Shirt",
            "cartQuantity": "1",
            "cartPrice": "$5.89"
        }
    ]
  }
}

Option 2: Data tags

Tags allow you to store and reference simple key: value pairs for personalization. Since arrays and objects aren’t supported, you’ll typically store only the last item added and how many total items in the cart. Example:

{
  "cartImageURL": "https://i.imgur.com/ssPCfbC.png",
  "cartProductName": "24 Pack of Acorns",
  "cartQuantity": "1",
  "cartPrice": "$12.99",
  "cartItemsCount": "4",
  "cart_url": "https://yourdomain.com/cart"
}

Abandoned cart email template

This email template example will demonstrate how to display the following 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:

  • Custom Data: use the size property. Example: {{ message.custom_data.[key].size }}.
  • Data Tags: use the cartItemsCount tag. Example: {{ cartItemsCount }}.

Within our 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!

We're holding onto {{ cartItemsCount }} items in your cart, but don't wait too long, other squirrels are getting ahead!

Display items in email

  • Custom Data: Use a Liquid for-loop to iterate over your custom_data cart array.
  • Data Tags: Only the most recent item will be shown based on your tag structure.

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.

If using Data Tags, you can remove the rows with the for-loop. Remember to change the liquid syntax based on your tag structure.

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 or tag like this: "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}} if using custom_data
  • {{cart_url}} if using tags

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.

For tags, you can send using any methods.


Abandoned Cart Push Setup

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 or cartItemsCount tag.

In the template Message field, add the following copy:

{% assign item_count = message.custom_data.cart.size | plus: 0 %}
{% if item_count == 1 %}
You left {{message.custom_data.cart.first.cartProductName}} in your cart.
{% endif %}
{% if item_count == 2 %}
You left {{message.custom_data.cart.first.cartProductName}} and {{item_count | minus: 1}} more item in your cart.
{% endif %}
{% if item_count > 2 %}
You left {{message.custom_data.cart.first.cartProductName}} and {{item_count | minus: 1}} more items in your cart.
{% endif %}

In this example, we assign the variable item_count to be the custom_data.cart.size or the tag cartItemsCount and if that count is equal to 1, 2 or more than 2, display different content.

Due to the cart may 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"}}
  • {{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 tag, you can use the remove feature of liquid syntax as follows:

  • https://{{message.custom_data.cart_url | remove: "https://"}}
  • https://{{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.

If using tags, you can send using any of OneSignal’s options for Sending Messages.

Need help?

Chat with our Support team or email support@onesignal.com

Please 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!