Learn how to create abandoned cart reminder templates with OneSignal using custom data or data tags, and deliver them through email and push notifications.
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:
custom_data
API parameter to pass structured data from your server, orcustom_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:
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:
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:
link to the customer’s personalized cart URL
Abandoned cart email template example
Create a new email template
Navigate to Messages > Templates > New Email Template.
Use the Drag & Drop Editor
Create a 5 rows with the following:
Abandoned cart email template setup
Using Liquid syntax, show the number of products:
size
property. Example: {{ message.custom_data.[key].size }}
.cartItemsCount
tag. Example: {{ cartItemsCount }}
.Within our template row 1 Text block, set your copy as desired. Example:
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:
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
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 tagsAbandoned cart email template example for custom URL
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.
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 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
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:
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.
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"}}
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://"}}
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:
We’re happy to help!
Learn how to create abandoned cart reminder templates with OneSignal using custom data or data tags, and deliver them through email and push notifications.
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:
custom_data
API parameter to pass structured data from your server, orcustom_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:
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:
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:
link to the customer’s personalized cart URL
Abandoned cart email template example
Create a new email template
Navigate to Messages > Templates > New Email Template.
Use the Drag & Drop Editor
Create a 5 rows with the following:
Abandoned cart email template setup
Using Liquid syntax, show the number of products:
size
property. Example: {{ message.custom_data.[key].size }}
.cartItemsCount
tag. Example: {{ cartItemsCount }}
.Within our template row 1 Text block, set your copy as desired. Example:
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:
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
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 tagsAbandoned cart email template example for custom URL
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.
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 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
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:
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.
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"}}
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://"}}
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:
We’re happy to help!