Skip to main content
Contributor III
March 2, 2024
Solved

HELP - added ro cart event - shopidy v 1.0 theme

  • March 2, 2024
  • 1 reply
  • 80 views

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]);

});

</script>

 

 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);

}

</script>





 

    This topic has been closed for replies.
    Best answer by retention

    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.”  

    https://outofthesandbox.com/products/turbo-theme-florence

     

    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?

    1 reply

    retention
    Partner - Platinum
    retentionAnswer
    2025 Champion
    March 3, 2024

    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.”  

    https://outofthesandbox.com/products/turbo-theme-florence

     

    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?

    Joseph Hsieh // retentioncommerce.com // X: @retention