In this article, we will show you how to create a dynamic abandoned cart email template in HubSpot using personalization tokens created by the Magento HubSpot integration.


1. Create a Custom Module in HubSpot


Create HubSpot Magento Abandoned Cart Email


2. Click Create New File


Create HubSpot Magento Abandoned Cart Email


3. Select Module


Create HubSpot Magento Abandoned Cart Email


4. Configure new Module


Create HubSpot Magento Abandoned Cart Email


5. Populate the new module with the following code (this code contains the clickable names and images of the abandoned cart items):


{% if contact.eyemagine_abandoned_item_product_name_1 is defined and contact.eyemagine_abandoned_item_product_name_1 ne '-' %}
<p><a href="{{ contact.eyemagine_abandoned_item_product_url_1 }}"><img src="{{ contact.eyemagine_abandoned_item_product_img_1 }}" alt="{{ contact.eyemagine_abandoned_item_product_name_1 }}" /> </a></p>
<p><a href="{{ contact.eyemagine_abandoned_item_product_url_1 }}">{{ contact.eyemagine_abandoned_item_product_name_1 }}</a></p>
{% endif %}

{% if contact.eyemagine_abandoned_item_product_name_2 is defined and contact.eyemagine_abandoned_item_product_name_2 ne '-' %}
<p><a href="{{ contact.eyemagine_abandoned_item_product_url_2 }}"><img src="{{ contact.eyemagine_abandoned_item_product_img_2 }}" alt="{{ contact.eyemagine_abandoned_item_product_name_2 }}" /> </a></p>
<p><a href="{{ contact.eyemagine_abandoned_item_product_url_2 }}">{{ contact.eyemagine_abandoned_item_product_name_2 }}</a></p>
{% endif %}

{% if contact.eyemagine_abandoned_item_product_name_3 is defined and contact.eyemagine_abandoned_item_product_name_3 ne '-' %}
<p><a href="{{ contact.eyemagine_abandoned_item_product_url_3 }}"><img src="{{ contact.eyemagine_abandoned_item_product_img_3 }}" alt="{{ contact.eyemagine_abandoned_item_product_name_3 }}" /> </a></p>
<p><a href="{{ contact.eyemagine_abandoned_item_product_url_3 }}">{{ contact.eyemagine_abandoned_item_product_name_3 }}</a></p>
{% endif %}


5a. Select Enable module for programmable email

Create HubSpot Magento Abandoned Cart Email


6. Save Module


7. Create a new Email

Create HubSpot Magento Abandoned Cart Email


Create HubSpot Magento Abandoned Cart Email

8. Select your template or create a new one and insert the Module we created in the steps above


Create HubSpot Magento Abandoned Cart Email

9. Drag the Module into your email template


Create HubSpot Magento Abandoned Cart Email



SUMMARY: Test the email template using a contact record with multiple items in the abandoned cart.