Jump to content

Track Add to cart button in GA


Recommended Posts

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

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

  • 3 months later...

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

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

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

  • 1 year later...

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

×
×
  • Create New...