Jump to content

GA trackEvent productname with jquery not working


Recommended Posts

Hi, 

 

In order to track sales of products under "Customers who bought this product also bought" I added below code to the product.tpl page. The event is being tracked, but the product name which I try to retrieve using jQuery remains empty. 

 

I'm sure it's just a simpe coding error.. any help would be appreciated

 

The code I added to product.tpl :

<script type="text/javascript">
$( document ).ready(function() {
    var crossprod_name = $('.s_title_block > a').attr('title');

    $('a.ajax_add_to_cart_button').on("tap click", (function() {
        _gaq.push(['_trackEvent', 'Cart', 'AddCrossSale', '{$product->name} - {$crossprod_name} ']);
    }));


  });


</script>
Link to comment
Share on other sites

×
×
  • Create New...