Skip to main content

I have looked at all of the other posts on here to see if it would help me. Alas, I’m still struggling. Can someone take a look and see if this at least looks right so I know if it is or isn’t a ‘ME’ problem?

 

This is what comes up with Inspect Element on the Add to Cart Button, so I was at least able to figure out that it was Snippet 2 that I needed to use (I think).

Here’s my inserted and updated code within the theme on Shopify. 

Thanks for any pointers you can give. 

Hi@smays ,

Welcome to the Community!

My guess here is that your add to cart variable after “.getElementById” is probably causing issues with the button and section_id variable.

I think one idea would be to try 

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

to trigger add to cart metrics. You may just need to also check with your developers that no other buttons share the same class name 'btn' as it is a generic name, if there are other buttons with this, they may also trigger the add to cart event. 

 

Let me know if that works if not then we will reconsider.


Reply