Set Up Reclaim for Add to Cart

Using Reclaim Add to Cart

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 tool 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 Attentive, 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 product.liquid file (if not found there, try the product.json or 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((typeof settings != "undefined") && 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((typeof settings != "undefined") && 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: SET UP YOUR FLOW(S)

Once your existing Klaviyo snippet is modified/edited to include our script, you will see our additional unique identifier: CartSource: GE, as seen below in a contact profile in Klaviyo:

Additionally, you can see these events successfully passing through in your Retention.com account when you see the Added to Cart option populate under Event Details. This is an easy way to confirm that our events have been successfully implemented:

STEP 1

Copy your existing Add to Cart abandonment flow in Klaviyo (not Abandoned checkout or Product/browse abandonment!) and name it Reclaim Add to Cart. 

Edit the Trigger Filter to include  Dimension where CartSource> Equals > GE and Save. If you’re creating a new flow from scratch, use the Added to Cart event and use the same Trigger Filter specified in the previous sentence.

If you don’t already have them, you should also add flow filters to exclude anyone who has Started Checkout or Placed Order (ie, what someone has/has not done > placed order > 0 times) before landing in this flow, eg:

STEP 2

Add a 30 minute delay after the Trigger.

STEP 3

Add a conditional split. The purpose of this is 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 to compare performance between the two segments.

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

Select Properties about someone > data_source > equals GE:

STEP 4

Copy your flow content over to the No side of the split – both sides should receive the same email flows.

STEP 5

Modify your original abandoned cart flow to exclude any contacts with CartSource equals GE. This will be a Trigger Filter where the Dimension should be set to CartSource is not set:

STEP 6

Contact us at support[at]retention.com and request that we enable Add to Cart events for your account. If you’re working with our onboarding team, this will already be enabled.