diff --git a/modules/ganalytics/header.tpl b/modules/ganalytics/header.tpl index 35a966bc..12bd4841 100755 --- a/modules/ganalytics/header.tpl +++ b/modules/ganalytics/header.tpl @@ -28,24 +28,24 @@ ga('require', 'ec'); {foreach from=$items item=item} - ga('ec:addProduct', { // Provide product details in an productFieldObject. - 'id': '{$item.SKU}', // Product ID (string). - 'name': '{$item.Product}', // Product name (string). - 'category': '{$item.Category}', // Product category (string). - 'brand': '{$item.Category}', // Product brand (string). - 'price': '{$item.Price}', // Product price (currency). - 'quantity': {$item.Quantity} // Product quantity (number). - }); + ga('ec:addProduct', { // Provide product details in an productFieldObject. + 'id': '{$item.SKU}', // Product ID (string). + 'name': '{$item.Product}', // Product name (string). + 'category': '{$item.Category}', // Product category (string). + 'brand': '{$item.Category}', // Product brand (string). + 'price': '{$item.Price}', // Product price (currency). + 'quantity': {$item.Quantity} // Product quantity (number). + }); {/foreach} - {if $analytics_timeover == 0} + {if $cookie->transCpt < 2} ga('ec:setAction', 'purchase', { // Transaction details are provided in an actionFieldObject. - 'id': '{$trans.id}', // (Required) Transaction id (string). - 'affiliation': '{$trans.store}', // Affiliation (string). - 'revenue': '{$trans.total}', // Revenue (currency). - 'tax': '{$trans.tax}', // Tax (currency). - 'shipping': '{$trans.shipping}', // Shipping (currency). - }); + 'id': '{$trans.id}', // (Required) Transaction id (string). + 'affiliation': '{$trans.store}', // Affiliation (string). + 'revenue': '{$trans.total}', // Revenue (currency). + 'tax': '{$trans.tax}', // Tax (currency). + 'shipping': '{$trans.shipping}', // Shipping (currency). + }); {/if} {literal} diff --git a/override/controllers/OrderConfirmationController.php b/override/controllers/OrderConfirmationController.php index 1bd233c0..8500c484 100755 --- a/override/controllers/OrderConfirmationController.php +++ b/override/controllers/OrderConfirmationController.php @@ -52,8 +52,6 @@ class OrderConfirmationController extends OrderConfirmationControllerCore $transCpt = (int) $cookie->transCpt; } $transCpt++; - $cookie->transCpt = $transCpt; - $cookie->write(); if ($transCpt > 1) { $analytics_timeover = 1; } @@ -67,8 +65,13 @@ class OrderConfirmationController extends OrderConfirmationControllerCore if (time() > $timestamp) { $analytics_timeover = 1; + $transCpt++; } } + + // Write cookie + $cookie->transCpt = $transCpt; + $cookie->write(); self::$smarty->assign( array(