Skip to main content

I'm struggling here. I'm using Canopy Theme and when we updated to Shopify 2.0, it knocked out our Added to Cart code. Now I can't get it to work again.

 

Here's my button code:

 

<button type="submit" name="add" class="btn product-add mini-form" data-btn-type="add-to-cart">

              <span class="button-text">Add to cart</span>

              <span class="loading-spinner" aria-label="Adding"></span>

             </button>

 

Here's where I customized the snippet:

 

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

 

 

Did I customize the snippet incorrectly?

 

Thanks!

 

 

Hi there @reneewood8

 

Happy to help!

 

Have you tried removing the “data-btn-type=”add-to-cart” section from your snippet and only having the “btn product-add mini-form” within the parentheses after the .getElementsByClassName section of your snippet? When adding in the class snippet,  you should only add what’s in the quotation marks for the ‘Added to Cart’ for the class button snippet, as seen below.

 

I can see that we have an awesome member of our support team helping you troubleshoot this problem, however, i would double check that this isn’t what’s causing the metric not to fire along with following along with our support team members last bit of instructions! Additionally, we also have a guide for Shopify 2.0 themes specifically,, you will need to add this snippet to the custom liquid block. 

 

Hope this helps!

-Taylor 


Reply