StoneTrader Posted April 13, 2015 Share Posted April 13, 2015 The official ganalytics module appears to be recording orders twice in Google Analytics: once when the product is ordered and again when it is shipped. Is anyone else experiencing this problem? Does anyone know what part of the "shipping" process could cause this to happen? We have recently upgraded from PrestaShop v1.4 to v1.6.0.11. We have v2.0.9 of the Google Analytics module. Link to comment Share on other sites More sharing options...
StoneTrader Posted April 13, 2015 Author Share Posted April 13, 2015 I wonder if the problem is related to our Google Analytics settings? We do *not* have Enhanced E-Commerce Settings enabled... ought we to? Link to comment Share on other sites More sharing options...
PascalVG Posted April 13, 2015 Share Posted April 13, 2015 I believe not: I quote: Important: The Enhanced Ecommerce plug-in should not be used alongside the Ecommerce (ecommerce.js) plug-in for the same property.). (see more on gAnalytics module here: http://nemops.com/setting-google-analytics-prestashop/#.VSv1XBOUee4 Sorry,no deep experience with this module. Anyone?? My 2 cents, pascal. Link to comment Share on other sites More sharing options...
StoneTrader Posted April 14, 2015 Author Share Posted April 14, 2015 Thanks for the link Pascal. Update on the issue: the trigger for the order being recorded again in Analytics does *not* appear to be the order being shipped. We have an order (transaction) recorded yesterday and again today but it's status remains "Payment accepted". My assumption is that some visitor activity, when returning to the site, is causing the GA event to be re-triggered? Link to comment Share on other sites More sharing options...
StoneTrader Posted April 14, 2015 Author Share Posted April 14, 2015 OK, we have found the problem. The ganalytics flow for addTransaction appears to work as follows: In hookOrderConfirmation: 1) Entry for order written to ps_ganalytics MySQL table with flag sent=0 2) JavaScript Google Analytics (GA) transaction tag built and returned to front-end 3) JS GA script called (via addTransaction wrapper) 4) Callback on successful addTransaction makes ajax call (to modules/ganalytics/controllers/front/ajax.php) with the intention of updating MySQL row for order to sent=1 In hookBackOfficeHeader: 5) When this hook is called (from the back office) any entries in ps_ganalytics with a flag of sent=0 and vintage of >20 minutes are selected 6) JS GA transaction code is re-built for each of these entries and rethrown Presumably the back office hook is intended to catch any failed calls to addTransaction, however we are seeing the ajax call in (4) fail *despite* the fact that the GA tag has been successfully thrown. This seems to occur for all Guest orders, with the culpable line from modules/ganalytics/controllers/front/ajax.php being line 38: $this->context->cookie->id_customer is empty for a Guest checkout so the script dies before updating the MySQL (regardless of whether the GA JS has been called or not), leaving sent=0. Subsequent access to the back office (usually to ship order) causes the GA tag to be fired again. public function initContent() { parent::initContent(); $order = new Order((int)Tools::getValue('orderid')); if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->cookie->id_customer) die; Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'ganalytics` SET sent = 1, date_add = NOW() WHERE id_order = '.(int)Tools::getValue('orderid').' LIMIT 1'); die; } } Link to comment Share on other sites More sharing options...
StoneTrader Posted April 14, 2015 Author Share Posted April 14, 2015 The validation check seems largely futile since it is in no way connected to whether or not the GA code ran. As a temporary fix we have removed lines 38 and 39 from our module. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now