dorje Posted June 17, 2013 Share Posted June 17, 2013 Hi everyone I want to track the add to cart button in GA and i have set up tracking event and GA is showing me the events but with no actionable data. http://www.prestasho...54#entry1261454 I just want to edit this thing to get the data real data for more conversion analysis I added the _gaq.push(['_trackEvent', 'cart', 'Add to cart', 'product added to cart']); after function and its showing the event in the GA.as it is told in the above post But i want this as _trackEvent(category, action, opt_label, opt_value, opt_noninteraction) whereas category= our store category, action = Add to cart , opt_label = Product name, Opt_value = price.... So can u tell me how to add the value dynamically inside the track event to get the date as i dont know much about programming. Link to comment Share on other sites More sharing options...
vekia Posted June 17, 2013 Share Posted June 17, 2013 everything depends on place, where you've got add to cart button it is product page? or it is product listing? Link to comment Share on other sites More sharing options...
dorje Posted June 18, 2013 Author Share Posted June 18, 2013 In products page www.kathmanduclothing.com it's the site and i am getting the reports in GA but not those kind of reports that i want Look in this post for the report http://www.blog.analyticsinspector.com/how-to-track-products-added-to-basket-in-google-analytics/ Buy this trick we can know which product are most added by our visitore by which kind of traffic .etc etc which will ultimately help us in more conversion. I saw the tracking for magento then why not for prestashop Link to comment Share on other sites More sharing options...
vekia Posted June 18, 2013 Share Posted June 18, 2013 you can use these variables: category {$product->category} opt_label {$product->name} opt_value {convertPrice price=$productPrice} Link to comment Share on other sites More sharing options...
pedrogon Posted September 18, 2013 Share Posted September 18, 2013 Hi Vekia (and everyone), I'm in the same situation of Dorje. I want to track the event both in the product page and in the product listing. This works for me (configured following this instructions: http://www.prestashop.com/forums/topic/253411-track-add-to-cart-button-in-ga/?p=1261454&do=findComment&comment=1261454): _gaq.push(['_trackEvent', 'cart', 'Add to cart', 'product added to cart']); But I want to pass the product names dynamically. I've tried this, but it doesn't work: _gaq.push(['_trackEvent', 'cart', 'Add to cart', '{$product->name}']); I guess it's not that easy. I've searched quite a lot but I didn't find anything and I'm not a programmer. Could somebody please tell me what specific code do I have to use to pass the product name? Thanks a lot. Link to comment Share on other sites More sharing options...
vekia Posted September 18, 2013 Share Posted September 18, 2013 can you show how your code looks like ? not only part with _gaq.push(); but also other part of button Link to comment Share on other sites More sharing options...
pedrogon Posted September 19, 2013 Share Posted September 19, 2013 Of course. This is the code of the "add" buttons part (I'm using j2tajaxcart, not the default blockcart module): //override every button in the page in relation to the cart overrideButtonsInThePage : function(){ //for every 'add' buttons... if ($('.j2t-overlay').length == 0){ $('body').append('<div class="j2t-overlay"></div>'); $('.j2t-overlay').click(function (){ j2tajaxCart.hideJ2tOverlay(); }); var loading_html = '<div class="j2t-loading-data" id="j2t-loading-data">'+j2t_pre_box+'<div class="j2t-ajax-child"><div class="inner-ajax-content"><img alt="'+j2t_loading_txt+'" src="'+loading_url+'" /><p>'+j2t_loading_txt+'</p></div></div>'+j2t_post_box+'</div>'; $('body').append('<div class="j2tajax-progress" id="j2t_ajax_progress">'+loading_html+'</div>'); } $('.j2t_ajax_add_to_cart_button').unbind('click').click(function(){ var idProduct = $(this).attr('rel').replace('ajax_id_product_', ''); if ($(this).attr('disabled') != 'disabled'){ j2tajaxCart.add(idProduct, null, false, this); _gaq.push(['_trackEvent', 'cart', 'Add to cart', '{$product->name}']); j2tajaxCart.showLoading(); } return false; }); //for product page 'add' button... //$('body#product p#j2t_add_to_cart input').unbind('click').click(function(){ $('body#product p#add_to_cart input').unbind('click').click(function(){ j2tajaxCart.add( $('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null); _gaq.push(['_trackEvent', 'cart', 'Add to cart', '{$product->name}']); j2tajaxCart.showLoading(); return false; }); }, Link to comment Share on other sites More sharing options...
vekia Posted September 19, 2013 Share Posted September 19, 2013 thanks, this is part of .js file or .tpl ? Link to comment Share on other sites More sharing options...
pedrogon Posted September 19, 2013 Share Posted September 19, 2013 js (/modules/j2tajaxcart/j2tajaxcart.js) Link to comment Share on other sites More sharing options...
vekia Posted September 20, 2013 Share Posted September 20, 2013 so this variable will not work in this file, you need to use a bit different method (maybe pass variable to js from the .tpl file) i don't know this addon and script, but i suppose that you will have to modify script and also theme template files. Link to comment Share on other sites More sharing options...
pedrogon Posted September 20, 2013 Share Posted September 20, 2013 Thanks vekia, could you please tell me how that would be done with the default blockcart module? (we are thinking of going back to that module and abandon j2tajaxcart) Thanks again for all your help! Link to comment Share on other sites More sharing options...
vekia Posted September 20, 2013 Share Posted September 20, 2013 you will need to add function to the button in tpl file i mean something like onclick="_gaq.push(['_trackEvent', 'cart', 'Add to cart', '{$product->name}'])" Link to comment Share on other sites More sharing options...
pedrogon Posted September 20, 2013 Share Posted September 20, 2013 OK, but add that function in what tpl file? I've been looking to blockcart module and it has two tpl (blockcart.tpl and blockcart-json.tpl) but I don't see where that code would fit in them (maybe I'm wrong, but they seem to refer to the block of products added to the cart, not to the "add to cart" button). Sorry for asking this much, but I'm still learning... Link to comment Share on other sites More sharing options...
vekia Posted September 20, 2013 Share Posted September 20, 2013 you have to add this everywhere, where the add to cart button appears for example: product.tpl file and product-list.tpl Link to comment Share on other sites More sharing options...
pedrogon Posted September 23, 2013 Share Posted September 23, 2013 Thanks Vekia, It's working! Link to comment Share on other sites More sharing options...
ADNartesano Posted May 6, 2015 Share Posted May 6, 2015 Hi Vekia, pedrogon, I'm trying to do this for my shop and it's imposible for me. Could you explain me how did you do this? I have modified .tpl and .js files and doesn't work for me. I have tried adding: _gaq.push(['_trackEvent', 'cart', 'Add to cart', 'product added to cart']); and ga('send', 'event', 'cart', 'Add to cart', 'product added to cart'); I'm using Prestashop 1.6 with default-bootstrap template and default blockcart module. Thanks in advanced! Link to comment Share on other sites More sharing options...
Recommended Posts