HELP - added ro cart event - shopidy v 1.0 theme

  • 2 March 2024
  • 1 reply

Badge +4

I have gone through all documentation and conversations and help in community here > and still cannot get Added to Cart working
I had it working in this theme several theme versions agon - however client remvoved those theme copies

Using Turbo Florence theme 
It uses a class for add to cart > add_to_cart.action_button
Viewed product is working correctly - and I have been adding added to card snippet scrript under the Viewed product script
Is this incorrect placement?
I did try in theme.liquid without success
Previously when was working - it was added to product theme.liquid under viewed product snippet
At that time only had access to  ID for add to cart button > and I added and ID to add to cart button code in the theme to get working


script text="text/javascript">

var _learnq = _learnq || [];

document.getElementById("AddToCart").addEventListener('click',function (){

  _learnq.push(['track', 'Added to Cart', item]);




 Current code snippet I have tried  in current theme >


<script type="text/javascript">

var _learnq = _learnq || [];

  var classname = document.getElementsByClassName(“add_to_cart.action_button”);

var addToCart = function() {

_learnq.push(['track', 'Added to Cart', item]);

}; for (var i = 0; i < classname.length; i++) {

classname[i].addEventListener('click', addToCart, false);





Best answer by retention 3 March 2024, 21:58

View original

1 reply

Userlevel 7
Badge +58

Hi @DarleenW,

Not being able to see your site’s source code, so it might be different, but I’m using the example site from the theme developer (Out Of The Sandbox) here as a reference for the “Turbo Florence Theme.”


Looking at it’s source code, I see the “Add to Cart” button code as follows:

<button type="button" name="add" class="ajax-submit action_button add_to_cart" data-label="Add to Cart">

Then, your code to reference this button should be:

var classname = document.getElementsByClassName(“ajax-submit action_button add_to_cart”);


Note, I didn’t use the dot notation like you did in your code example. So maybe you want to try that.

This is using the snippet 3 example form Klaviyo’s documentation here:

Give that a try and let us know if it worked?