Add counter for purchase transaction

This commit is contained in:
Michael RICOIS 2018-01-23 16:38:06 +01:00
parent d0c9e8f59b
commit 9b3f4d087b
2 changed files with 29 additions and 14 deletions

View File

@ -38,7 +38,7 @@
});
{/foreach}
{/literal}{if $analytics_timeover == 0}{literal}
{if $analytics_timeover == 0}
ga('ec:setAction', 'purchase', { // Transaction details are provided in an actionFieldObject.
'id': '{$trans.id}', // (Required) Transaction id (string).
'affiliation': '{$trans.store}', // Affiliation (string).
@ -46,7 +46,7 @@
'tax': '{$trans.tax}', // Tax (currency).
'shipping': '{$trans.shipping}', // Shipping (currency).
});
{/literal}{/if}{literal}
{/if}
{literal}
var re = new RegExp("([?&])(email=)[^&#]*", "g");

View File

@ -43,17 +43,32 @@ class OrderConfirmationController extends OrderConfirmationControllerCore
$products = SaleDelay::associateDelay($products);
}
// Set cookie
$analytics_timeover = 0;
$transCpt = 0;
// Cookie
global $cookie;
if (isset($cookie->transCpt)) {
$transCpt = (int) $cookie->transCpt;
}
$transCpt++;
$cookie->transCpt = $transCpt;
$cookie->write();
if ($transCpt > 1) {
$analytics_timeover = 1;
}
// Check date order if page is refresh and not affect analytics
if ($analytics_timeover == 0) {
$timestamp_check = new DateTime();
$timestamp_check->createFromFormat('Y-m-d H:i:s', $order->date_add);
$timestamp_check->add(new DateInterval('PT10M'));
$timestamp = $timestamp_check->getTimestamp();
$analytics_timeover = 0;
if (time() > $timestamp) {
$analytics_timeover = 1;
}
}
self::$smarty->assign(
array(