How to Set Up Reclaim for Add to Cart

Using Reclaim Add to Cart Feature

This feature can identify abandoned cart contents for both unknown, non-logged in users (Resolve contacts) and known, non-logged in customers (emails in your Resolve suppression list). 

If you use this feature, we will send all of those Add to Cart events to you. 

To use this feature, you must first ensure that you’re using the most recent version of our script on your website. You can find your script in your  account under Code Script > View Script

This feature works for any e-commerce website, we will show examples for Shopify in this tutorial.

Click here for a link to all our tutorials on how to add the script to your site, in case you need a refresher.

At present we can sync Add to Cart events to Klaviyo, Mailchimp, and Drip. 

ON YOUR WEBSITE:

1. Add the following script to the on-click event for adding an item to your cart, such as an “Add to Cart” button:

geq.addToCart(item);
This feature works for any e-commerce platform, but we have specific examples for Shopify:
IN SHOPIFY

If you are already using Klaviyo’s Add to Cart feature with Shopify, you can skip this section because it’s already set up and working. However, you will need to determine ahead of time which snippet you’re using to quickly/easily identify it in Shopify.

  1. Use Klaviyo’s AddtoCart documentation to determine which snippet type you’re using. 
  2. Edit your Klaviyo Add to Cart script in Shopify.
    a. In Shopify, navigate to Online Store > Themes
    b. Find your theme and click Customize
    c. Click the three dots at the top and select Edit code
    d. Open the theme.liquid file 
Edit the snippet
 
 

Snippet 1: For buttons without redirects

You should update your script from this:

<script type="text/javascript">
var _learnq = _learnq || [];
function addedToCart() {
  fetch(`${window.location.origin}/cart.js`)
  .then(res => res.clone().json().then(data => {
    var cart = {
      total_price: data.total_price/100,
      $value: data.total_price/100,
      total_discount: data.total_discount,
      original_total_price: data.original_total_price/100,
      items: data.items
    }
    if (item !== 'undefined') {
      cart = Object.assign(cart, item)
    }
    _learnq.push(['track', 'Added to Cart', cart])
  }))
} 
(function (ns, fetch) {
  ns.fetch = function() {
    const response = fetch.apply(this, arguments);
    response.then(res => {
      if (`${window.location.origin}/cart/add.js`
      	.includes(res.url)) {
        	addedToCart()
      }
    });
    return response
  }
}(window, window.fetch))
$(document).ajaxComplete(function(event, request, settings){
  if(settings.url == "/cart/add.js"){
      addedToCart()
  }
})</script>

to this:

<script type="text/javascript">
var _learnq = _learnq || [];
function addedToCart() {
  fetch(`${window.location.origin}/cart.js`)
  .then(res => res.clone().json().then(data => {
    var cart = {
      total_price: data.total_price/100,
      $value: data.total_price/100,
      total_discount: data.total_discount,
      original_total_price: data.original_total_price/100,
      items: data.items
    }
    if (item !== 'undefined') {
      cart = Object.assign(cart, item)
    }
    _learnq.push(['track', 'Added to Cart', cart])
geq.addToCart(item); })) } (function (ns, fetch) { ns.fetch = function() { const response = fetch.apply(this, arguments); response.then(res => { if (`${window.location.origin}/cart/add.js` .includes(res.url)) { addedToCart() } }); return response } }(window, window.fetch)) $(document).ajaxComplete(function(event, request, settings){ if(settings.url == "/cart/add.js"){ addedToCart() } })</script>

Snippet 2: For buttons with redirects defined by a button ID

You should update your script from this:

<script type="text/javascript">
var _learnq = _learnq || [];
	document.getElementById("AddToCart").addEventListener('click',function (){
 		_learnq.push(['track', 'Added to Cart', item]);
	});</script>

to this:

<script type="text/javascript">
var _learnq = _learnq || [];
	document.getElementById("AddToCart").addEventListener('click',function (){
 		_learnq.push(['track', 'Added to Cart', item]);
geq.addToCart(item);
	});</script>

 

Snippet 3: For buttons with redirects defined by class notation

You should update your script from this:

<script type="text/javascript">
var _learnq = _learnq || [];
  var classname = document.getElementsByClassName("add-to-cart");
var addToCart = function() {
_learnq.push(['track', 'Added to Cart', item]);
}; for (var i = 0; i < classname.length; i++) {
classname[i].addEventListener('click', addToCart, false);
}
</script>

to this:

<script type="text/javascript">
var _learnq = _learnq || [];
  var classname = document.getElementsByClassName("add-to-cart");
var addToCart = function() {
_learnq.push(['track', 'Added to Cart', item]);
geq.addToCart(item); }; for (var i = 0; i < classname.length; i++) { classname[i].addEventListener('click', addToCart, false); } </script>

IN KLAVIYO

1. Assuming you already have Klaviyo’s AddedtoCart event set up,  you’ll need to determine which snippet you are using. Use their AddtoCart documentation to do this. 

We will check the Add to Cart event against all of your known users and sync it to Klaviyo.

If everything goes as planned, it should appear like a normal AddToCart event.

 We include CartSource: GE in the data:

2. Create a Flow in Klaviyo with the Metric trigger for Added to Cart and include a Trigger Filter for a Dimension where CartSource> Equals > GE and Save.

If you want to create a fork in your flow for those who are Retention.com contacts (ie, unknown, not logged in) and those that are known but not logged in, create a Conditional Split.

Note that this requires our Klaviyo integration identifier to be turned on. Contact us if you need this enabled. 

This allows you to create a split for your Retention.com and non Retention.com contacts, where Properties about someone > data_source > equals GE:

If you set it up as seen above, we recommend you also modify your original abandoned cart flow to exclude any contacts with CartSource equals GE (or only send to those with CartSource is not set).

3. Contact us at support[at]retention.com and request that we enable Add to Cart events for your account. If you have integrations with multiple ESPs, please clarify which one we’re syncing to if it’s not Klaviyo.