Learn how to create abandoned cart reminder templates with OneSignal using custom data or data tags, and deliver them through email and push notifications.
custom_data
API parameter to pass structured data from your server, orcustom_data
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:
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:
Abandoned cart email template example
Create a new email template
Use the Drag & Drop Editor
Create a 5 rows with the following:
Abandoned cart email template setup
size
property. Example: {{ message.custom_data.[key].size }}
.cartItemsCount
tag. Example: {{ cartItemsCount }}
.custom_data
cart array.{% 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:
{{product.cartProductName}}
{{product.cartQuantity}}
{{product.cartPrice}}
{% 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
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
template_id
within your Create message API requests with custom_data
property.For tags, you can send using any methods.Abandoned cart push template example
cart
array of your custom_data
object or cartItemsCount
tag.
In the template Message field, add the following copy:
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.
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"}}
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://"}}
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.support@onesignal.com
Please include: