Turbo theme. Add to cart metric in Klaviyo.

DawsonReed
New Member
1 0 0

Hi, I'm trying to add the add to cart metric for Klaviyo into my .liquid, this is the scrip I believe I should be using because Turbo theme uses a class notation instead of an ID. 

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

However when I go into the inspect on my site for the add to cart button the "addtocart" part doesn't add up to what its supposed to, I believe. this is from the inspect on my sites add to cart button. 

<button type="button" name="add" class="ajax-submit action_button add_to_cart action_button--secondary" data-label="Add to Cart"> <span class="text">Add to Cart</span> <svg x="0px" y="0px" width="32px" height="32px" viewBox="0 0 32 32" class="checkmark"> <path fill="none" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" d="M9,17l3.9,3.9c0.1,0.1,0.2,0.1,0.3,0L23,11"></path></svg></button>

If anyone can let me know what I'm supposed to input into my .liquid to make this work id greatly appreciate it. Thank you for your time if you decide to help.

0 Likes