View Single Post
  #69  
Old 07-20-2016, 09:45 AM
 
aim aim is offline
Advanced Staff Users
 

X-Cart team
  
Join Date: Dec 2008
Posts: 928
 

Default Re: X-Cart 4.7.6 released: Improved Performance, Bugfixes

Quote:
Originally Posted by cflsystems
I just found the stock XC code for GA does not report ecommerce.

The template file has this condition to report ecommerce

Code:
{if $config.Google_Analytics.ganalytics_e_commerce_analysis eq "Y" and $ga_track_commerce eq "Y" and $main eq "order_message" and $orders }

but the $ga_track_commerce is always N on order confirmation page. It looks like this bug affects versions down to 4.4.x as far as I can tell. I have verified this to happen on 4.6.x and 4.7.x versions (live stores) and code is the same for 4.4.x and 4.5.x so it must be present there too.

There are 2 ways to fix it - one modifying cart.php and the other modifying the template used for the tracking.
Easiest is to delete the
Code:
and $ga_track_commerce eq "Y"
line from the template. This variable is useless anyway with the way code is written and it does nothing but to repeat what is already there. And of course to mess things up.

reported https://bt.x-cart.com/view.php?id=46300


The variable is assigned here
Code:
include/checkout.php-123-if ( include/checkout.php-124- !empty($active_modules['Google_Analytics']) include/checkout.php-125- && $config['Google_Analytics']['ganalytics_e_commerce_analysis'] == 'Y' include/checkout.php-126-) { include/checkout.php:127: $ga_track_commerce = 'Y';


The aim of the variable is to run this code one time per order on the 'thank for the order' page.


Code:
ga('ecommerce:addTransaction', {ldelim} 'id' : "{$order.order.orderid}", // order ID - required 'affiliation' : "{$partner|default:'Main stock'}", // affiliation or store name 'revenue' : "{$order.order.total}", // total - required 'shipping' : "{$order.order.shipping_cost}", // shipping 'tax' : "{$order.order.tax}" // tax {rdelim});



Thank you.
__________________
Sincerely yours,
Ildar Amankulov
Head of Maintenance group
Reply With Quote