Merge branch 'ticket/r11982-ganalytics' into develop

This commit is contained in:
Michael RICOIS 2018-01-17 10:23:43 +01:00
commit 69d2c02608
4 changed files with 813 additions and 762 deletions

View File

@ -4,21 +4,21 @@
ga('require', 'ecommerce', 'ecommerce.js'); ga('require', 'ecommerce', 'ecommerce.js');
ga('ecommerce:addTransaction', { ga('ecommerce:addTransaction', {
'id': '{$trans.id}', // Transaction ID. Required 'id': '{$trans.id}', // Transaction ID. Required
'affiliation': '{$trans.store}', // Affiliation or store name. 'affiliation': '{$trans.store}', // Affiliation or store name.
'revenue': '{$trans.total}', // Grand Total. 'revenue': '{$trans.total}', // Grand Total.
'shipping': '{$trans.shipping}', // Shipping. 'shipping': '{$trans.shipping}', // Shipping.
'tax': '{$trans.tax}' // Tax. 'tax': '{$trans.tax}' // Tax.
}); });
{foreach from=$items item=item} {foreach from=$items item=item}
ga('ecommerce:addItem', { ga('ecommerce:addItem', {
'id': '{$item.OrderId}', // Transaction ID. Required. 'id': '{$item.OrderId}', // Transaction ID. Required.
'name': '{$item.Product}', // Product name. Required. 'name': '{$item.Product}', // Product name. Required.
'sku': 'DD23444', // SKU/code. 'sku': 'DD23444', // SKU/code.
'category': '{$item.Category}', // Category or variation. 'category': '{$item.Category}', // Category or variation.
'price': '{$item.Price}', // Unit price. 'price': '{$item.Price}', // Unit price.
'quantity': '{$item.Quantity}' // Quantity. 'quantity': '{$item.Quantity}' // Quantity.
}); });
{/foreach} {/foreach}
@ -28,22 +28,22 @@
ga('require', 'ec'); ga('require', 'ec');
{foreach from=$items item=item} {foreach from=$items item=item}
ga('ec:addProduct', { // Provide product details in an productFieldObject. ga('ec:addProduct', { // Provide product details in an productFieldObject.
'id': '{$item.SKU}', // Product ID (string). 'id': '{$item.SKU}', // Product ID (string).
'name': '{$item.Product}', // Product name (string). 'name': '{$item.Product}', // Product name (string).
'category': '{$item.Category}', // Product category (string). 'category': '{$item.Category}', // Product category (string).
'brand': '{$item.Category}', // Product brand (string). 'brand': '{$item.Category}', // Product brand (string).
'price': '{$item.Price}', // Product price (currency). 'price': '{$item.Price}', // Product price (currency).
'quantity': {$item.Quantity} // Product quantity (number). 'quantity': {$item.Quantity} // Product quantity (number).
}); });
{/foreach} {/foreach}
ga('ec:setAction', 'purchase', { // Transaction details are provided in an actionFieldObject. ga('ec:setAction', 'purchase', { // Transaction details are provided in an actionFieldObject.
'id': '{$trans.id}', // (Required) Transaction id (string). 'id': '{$trans.id}', // (Required) Transaction id (string).
'affiliation': '{$trans.store}', // Affiliation (string). 'affiliation': '{$trans.store}', // Affiliation (string).
'revenue': '{$trans.total}', // Revenue (currency). 'revenue': '{$trans.total}', // Revenue (currency).
'tax': '{$trans.tax}', // Tax (currency). 'tax': '{$trans.tax}', // Tax (currency).
'shipping': '{$trans.shipping}', // Shipping (currency). 'shipping': '{$trans.shipping}', // Shipping (currency).
}); });
{literal} {literal}

View File

@ -16,19 +16,11 @@ class OrderConfirmationController extends OrderConfirmationControllerCore
$productIds[] = (int) $product['product_id']; $productIds[] = (int) $product['product_id'];
} }
$currency = Currency::getCurrency((int) $order->id_currency); self::$smarty->assign(array(
$currencyIsoCode = 'EUR'; 'order' => $order,
if (!empty($currency['iso_code'])) { 'productIds' => $productIds,
$currencyIsoCode = $currency['iso_code']; 'currency' => Currency::getCurrency((int) $order->id_currency),
} ));
self::$smarty->assign(
array(
'order' => $order,
'productIds' => $productIds,
'currency' => $currencyIsoCode,
)
);
} }
public function displayContent() public function displayContent()

View File

@ -27,416 +27,449 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#" xml:lang="{$lang_iso}"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#" xml:lang="{$lang_iso}">
<head> <head>
<title>{$meta_title|escape:'htmlall':'UTF-8'}</title> <title>{$meta_title|escape:'htmlall':'UTF-8'}</title>
{if isset($meta_description) AND $meta_description} {if isset($meta_description) AND $meta_description}
<meta name="description" content="{$meta_description|escape:html:'UTF-8'}" /> <meta name="description" content="{$meta_description|escape:html:'UTF-8'}" />
{/if} {/if}
{if isset($meta_keywords) AND $meta_keywords} {if isset($meta_keywords) AND $meta_keywords}
<meta name="keywords" content="{$meta_keywords|escape:html:'UTF-8'}" /> <meta name="keywords" content="{$meta_keywords|escape:html:'UTF-8'}" />
{/if} {/if}
{if isset($meta_fb_img) AND $meta_fb_img} {if isset($meta_fb_img) AND $meta_fb_img}
<meta property="og:image" content="{$meta_fb_img|escape:html:'UTF-8'}" /> <meta property="og:image" content="{$meta_fb_img|escape:html:'UTF-8'}" />
{/if} {/if}
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<meta name="robots" content="{if isset($nobots)}no{/if}index,follow" /> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="icon" type="image/png" href="{$img_ps_dir}preview.png?{$img_update_time}" /> <meta name="robots" content="{if isset($nobots)}no{/if}index,follow" />
<link rel="icon" type="image/vnd.microsoft.icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" /> <link rel="icon" type="image/png" href="{$img_ps_dir}preview.png?{$img_update_time}" />
<link rel="shortcut icon" type="image/x-icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" /> <link rel="icon" type="image/vnd.microsoft.icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" />
{if isset($page_name) && $page_name == 'authentication'} <link rel="shortcut icon" type="image/x-icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" />
<link rel="canonical" href="{$link->getPageLink('authentication.php', TRUE)}" /> {if isset($page_name) && $page_name == 'authentication'}
{/if} <link rel="canonical" href="{$link->getPageLink('authentication.php', TRUE)}" />
<script type="text/javascript"> {/if}
var baseDirSsl = '{$base_dir_ssl}'; <script type="text/javascript">
var baseDir = '{$content_dir}'; var baseDirSsl = '{$base_dir_ssl}';
var static_token = '{$static_token}'; var baseDir = '{$content_dir}';
var token = '{$token}'; var static_token = '{$static_token}';
var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals}; var token = '{$token}';
var priceDisplayMethod = {$priceDisplay}; var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals};
var roundMode = {$roundMode}; var priceDisplayMethod = {$priceDisplay};
var isoLang = "{$lang_iso}"; var roundMode = {$roundMode};
</script> var isoLang = "{$lang_iso}";
{if isset($css_files)} </script>
{if isset($css_files)}
{foreach from=$css_files key=css_uri item=media} {foreach from=$css_files key=css_uri item=media}
<link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" /> <link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" />
{/foreach} {/foreach}
{/if} {/if}
{if isset($js_files)} {if isset($js_files)}
{foreach from=$js_files item=js_uri} {foreach from=$js_files item=js_uri}
<script type="text/javascript" src="{$js_uri}"></script> <script type="text/javascript" src="{$js_uri}"></script>
{/foreach} {/foreach}
{/if} {/if}
<link rel="apple-touch-icon" href="{$base_dir_ssl}img/apple-touch-icon.png" /> <link rel="apple-touch-icon" href="{$base_dir_ssl}img/apple-touch-icon.png" />
{$HOOK_HEADER} {$HOOK_HEADER}
<!--[if IE 7]> <!--[if IE 7]>
<link href="{$css_dir}ie7.css" rel="stylesheet" type="text/css" media="screen" /> <link href="{$css_dir}ie7.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]--> <![endif]-->
<!--[if IE 8]> <!--[if IE 8]>
<link href="{$css_dir}ie8.css" rel="stylesheet" type="text/css" media="screen" /> <link href="{$css_dir}ie8.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]--> <![endif]-->
<!--[if IE 9]> <!--[if IE 9]>
<link href="{$css_dir}ie9.css" rel="stylesheet" type="text/css" media="screen" /> <link href="{$css_dir}ie9.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]--> <![endif]-->
<!-- Google Tag Manager --> <!-- Google Tag Manager -->
{literal} {literal}
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PT7ZGQF');</script> })(window,document,'script','dataLayer','GTM-PT7ZGQF');</script>
{/literal} {/literal}
<!-- End Google Tag Manager --> <!-- End Google Tag Manager -->
{assign var='isEC' value=Configuration::get('GANALYTICS_EC')} {assign var='isEC' value=Configuration::get('GANALYTICS_EC')}
{if $cookie->id_lang == 2} {if $cookie->id_lang == 2}
{literal} {literal}
<script> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-30665119-1', 'auto'); ga('create', 'UA-30665119-1', 'auto');
{/literal}
{if isset($page_name) && $page_name == 'category'}
{literal}
ga('require', 'ec');
{/literal}{if isset($page_name) && $page_name == 'category'}{literal} {/literal}
ga('require', 'ec'); {else if isset($page_name) && $page_name == 'product'}
{literal}
ga('require', 'ec');
ga('ec:addProduct', {
'id': {/literal}{$product->id}{literal},
'name': "{/literal}{$product->name|escape:'htmlall':'UTF-8'}{literal}",
'category': "{/literal}{$sale->title[$cookie->id_lang]}{literal}"
});
ga('ec:setAction', 'detail');
{/literal}{else if isset($page_name) && $page_name == 'product'}{literal} {/literal}
ga('require', 'ec'); {else if isset($page_name) && $page_name == 'order'}
ga('ec:addProduct', { {literal}
'id': {/literal}{$product->id}{literal}, ga('require', 'ec');
'name': "{/literal}{$product->name|escape:'htmlall':'UTF-8'}{literal}",
'category': "{/literal}{$sale->title[$cookie->id_lang]}{literal}"
});
ga('ec:setAction', 'detail'); {/literal}
{if $step == 0 || $step == 1}
{if $cart}
{assign var='cartProducts' value=$cart->getProducts()}
{foreach from=$cartProducts item=cartProduct}
{literal}
ga('ec:addProduct', {
'id': {/literal}{$cartProduct['id_product']}{literal},
'name': "{/literal}{$cartProduct['name']}{literal}",
'category': "{/literal}{$cartProduct['category']}{literal}",
'price': {/literal}{Tools::ps_round(Product::getPriceStatic((int)$cartProduct['id_product'], true, ((isset($cartProduct['id_product_attribute']) AND !empty($cartProduct['id_product_attribute'])) ? (int)($cartProduct['id_product_attribute']) : NULL), 2), 2)}{literal},
'quantity': {/literal}{$cartProduct['cart_quantity']}{literal}
});
{/literal}
{/foreach}
{/if}
{/if}
{literal}
{/literal}{else if isset($page_name) && $page_name == 'order'}{literal} {/literal}
ga('require', 'ec'); {if $step == 0}{literal}
//cart
ga('ec:setAction','checkout', {
'step': 1,
});
{/literal}
{else if $step == 1}{literal}
// address
ga('ec:setAction','checkout', {
'step': 2,
});
{/literal}
{else if $step == 2}{literal}
// carrier
ga('ec:setAction','checkout', {
'step': 3,
});
{/literal}
{else if $step == 3}{literal}
// payment
ga('ec:setAction','checkout', {
'step': 4,
});
{/literal}
{/if}
{/if}
{literal}
{/literal} {/literal}
{if $step == 0 || $step == 1} {if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}
{if $cart} {literal}
{assign var='cartProducts' value=$cart->getProducts()} // send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation'
{foreach from=$cartProducts item=cartProduct} var re = new RegExp("([?&])(email=)[^&#]*", "g");
{literal} var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g");
ga('ec:addProduct', { var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g");
'id': {/literal}{$cartProduct['id_product']}{literal}, if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) {
'name': "{/literal}{$cartProduct['name']}{literal}", // remove personal data from url before sending to GA
'category': "{/literal}{$cartProduct['category']}{literal}", url = window.location.search.replace(re, '$1$2');
'price': {/literal}{Tools::ps_round(Product::getPriceStatic((int)$cartProduct['id_product'], true, ((isset($cartProduct['id_product_attribute']) AND !empty($cartProduct['id_product_attribute'])) ? (int)($cartProduct['id_product_attribute']) : NULL), 2), 2)}{literal}, url = url.replace(re2, '$1$2');
'quantity': {/literal}{$cartProduct['cart_quantity']}{literal} url = url.replace(re3, '$1$2');
}); var page = window.location.pathname+url;
{/literal} ga('send', 'pageview', page);
{/foreach} } else {
{/if} ga('send', 'pageview');
{/if} }
{literal} {/literal}
{/if}
{literal}
{/literal}{if $step == 0}{literal} function onStepComplete(stepNumber, option, redirect, form) {
//cart ga('ec:setAction', 'checkout_option', {
ga('ec:setAction','checkout', { 'step': stepNumber,
'step': 1, 'option': option
}); });
{/literal}{else if $step == 1}{literal} if (redirect != null) {
// address ga('send', 'event', 'Checkout', 'Option', {
ga('ec:setAction','checkout', { hitCallback: function() {
'step': 2, document.location = redirect;
}); }
{/literal}{else if $step == 2}{literal} });
// carrier } else if (form != null) {
ga('ec:setAction','checkout', { ga('send', 'event', 'Checkout', 'Option', {
'step': 3, hitCallback: function() {
}); form.submit();
{/literal}{else if $step == 3}{literal} }
// payment });
ga('ec:setAction','checkout', { } else {
'step': 4, ga('send', 'event', 'Checkout', 'Option', {});
}); }
{/literal}{/if} }
{/if}{literal} function addToCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart');
}
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
}
</script>
{/literal}
{elseif $cookie->id_lang == 3}
{literal}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
{/literal}{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}{literal} ga('create', 'UA-68580471-1', 'auto');
// send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation' {/literal}
{if isset($page_name) && $page_name == 'category'}
{literal}
ga('require', 'ec');
var re = new RegExp("([?&])(email=)[^&#]*", "g"); {/literal}
var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g"); {else if isset($page_name) && $page_name == 'product'}
var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g"); {literal}
if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) { ga('require', 'ec');
// remove personal data from url before sending to GA ga('ec:addProduct', {
url = window.location.search.replace(re, '$1$2'); 'id': {/literal}{$product->id}{literal},
url = url.replace(re2, '$1$2'); 'name': "{/literal}{$product->name|escape:'htmlall':'UTF-8'}{literal}",
url = url.replace(re3, '$1$2'); 'category': "{/literal}{$sale->title[$cookie->id_lang]}{literal}"
var page = window.location.pathname+url; });
ga('send', 'pageview', page);
} else { ga('ec:setAction', 'detail');
ga('send', 'pageview');
}
{/literal}{/if}{literal} {/literal}
{else if isset($page_name) && $page_name == 'order'}
{literal}
ga('require', 'ec');
function onStepComplete(stepNumber, option, redirect, form) { {/literal}
ga('ec:setAction', 'checkout_option', { {if $step == 0 || $step == 1}
'step': stepNumber, {if $cart}
'option': option {assign var='cartProducts' value=$cart->getProducts()}
}); {foreach from=$cartProducts item=cartProduct}
if (redirect != null) { {literal}
ga('send', 'event', 'Checkout', 'Option', { ga('ec:addProduct', {
hitCallback: function() { 'id': {/literal}{$cartProduct['id_product']}{literal},
document.location = redirect; 'name': "{/literal}{$cartProduct['name']}{literal}",
} 'category': "{/literal}{$cartProduct['category']}{literal}",
}); 'price': {/literal}{Tools::ps_round(Product::getPriceStatic((int)$cartProduct['id_product'], true, ((isset($cartProduct['id_product_attribute']) AND !empty($cartProduct['id_product_attribute'])) ? (int)($cartProduct['id_product_attribute']) : NULL), 2), 2)}{literal},
} else if (form != null) { 'quantity': {/literal}{$cartProduct['cart_quantity']}{literal}
ga('send', 'event', 'Checkout', 'Option', { });
hitCallback: function() { {/literal}
form.submit(); {/foreach}
} {/if}
}); {/if}
} else { {literal}
ga('send', 'event', 'Checkout', 'Option', {});
} {/literal}
} {if $step == 0}
function addToCartToGA(product) { {literal}
ga('ec:addProduct', { //cart
'id': product.id, ga('ec:setAction','checkout', {
'name': product.name, 'step': 1,
'brand': product.category, });
'category': product.category, {/literal}
'variant' : product.variant, {else if $step == 1}
'price': product.price, {literal}
'quantity': product.qty // address
}); ga('ec:setAction','checkout', {
ga('ec:setAction', 'add'); 'step': 2,
ga('send', 'event', 'UX', 'click', 'add to cart'); });
} {/literal}
function removeFromCartToGA(product) { {else if $step == 2}
ga('ec:addProduct', { {literal}
'id': product.id, // carrier
'name': product.name, ga('ec:setAction','checkout', {
'brand': product.category, 'step': 3,
'category': product.category, });
'variant' : product.variant, {/literal}
'price': product.price, else if $step == 3}
'quantity': product.qty {literal}
}); // payment
ga('ec:setAction', 'remove'); ga('ec:setAction','checkout', {
ga('send', 'event', 'UX', 'click', 'remove to cart'); 'step': 4,
} });
</script> {/literal}
{/literal} {/if}
{elseif $cookie->id_lang == 3} {/if}
{literal} {literal}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-68580471-1', 'auto'); {/literal}
{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}
{literal}
// send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation'
var re = new RegExp("([?&])(email=)[^&#]*", "g");
var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g");
var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g");
if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) {
// remove personal data from url before sending to GA
url = window.location.search.replace(re, '$1$2');
url = url.replace(re2, '$1$2');
url = url.replace(re3, '$1$2');
var page = window.location.pathname+url;
ga('send', 'pageview', page);
} else {
ga('send', 'pageview');
}
{/literal}
{/if}
{literal}
{/literal}{if isset($page_name) && $page_name == 'category'}{literal} function onStepComplete(stepNumber, option, redirect, form) {
ga('require', 'ec'); ga('ec:setAction', 'checkout_option', {
'step': stepNumber,
'option': option
});
if (redirect != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
document.location = redirect;
}
});
} else if (form != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
form.submit();
}
});
} else {
ga('send', 'event', 'Checkout', 'Option', {});
}
}
function addToCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart');
}
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
}
</script>
{/literal}
{/if}
{/literal}{else if isset($page_name) && $page_name == 'product'}{literal} <!-- Facebook Pixel Code -->
ga('require', 'ec'); {if $cookie->id_lang == 2}
ga('ec:addProduct', { {literal}
'id': {/literal}{$product->id}{literal}, <script>
'name': "{/literal}{$product->name|escape:'htmlall':'UTF-8'}{literal}", !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
'category': "{/literal}{$sale->title[$cookie->id_lang]}{literal}" n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
}); n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
ga('ec:setAction', 'detail'); fbq('init', '585280634957856');
fbq('track', "PageView");
</script>
{/literal}
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=585280634957856&amp;ev=PageView&amp;noscript=1"/></noscript>
{elseif $cookie->id_lang == 3}
{literal}
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
{/literal}{else if isset($page_name) && $page_name == 'order'}{literal} fbq('init', '778018572325168');
ga('require', 'ec'); fbq('track', "PageView");
</script>
{/literal} {/literal}
{if $step == 0 || $step == 1} <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=778018572325168&amp;ev=PageView&amp;noscript=1"/></noscript>
{if $cart} {/if}
{assign var='cartProducts' value=$cart->getProducts()}
{foreach from=$cartProducts item=cartProduct} {literal}
{literal} <script>
ga('ec:addProduct', { fbq('track', 'ViewContent', {
'id': {/literal}{$cartProduct['id_product']}{literal}, content_name:'{/literal}{$page_name|escape:'html':'UTF-8'}{literal}'
'name': "{/literal}{$cartProduct['name']}{literal}", });
'category': "{/literal}{$cartProduct['category']}{literal}", </script>
'price': {/literal}{Tools::ps_round(Product::getPriceStatic((int)$cartProduct['id_product'], true, ((isset($cartProduct['id_product_attribute']) AND !empty($cartProduct['id_product_attribute'])) ? (int)($cartProduct['id_product_attribute']) : NULL), 2), 2)}{literal}, {/literal}
'quantity': {/literal}{$cartProduct['cart_quantity']}{literal} {if isset($facebook_validation) && $facebook_validation}
}); {literal}
{/literal} <script>
{/foreach} fbq('track', 'CompleteRegistration');
{/if} </script>
{/if} {/literal}
{literal} {/if}
{/literal}{if $step == 0}{literal} {if isset($page_name)}
//cart {if $page_name == 'order-confirmation' && isset($order)}
ga('ec:setAction','checkout', { {literal}
'step': 1, <script>
}); fbq('track', 'Purchase', {
{/literal}{else if $step == 1}{literal} value: '{/literal}{$order->total_paid}{literal}',
// address currency: "{/literal}{$currency['iso_code']}{literal}"
ga('ec:setAction','checkout', {
'step': 2,
});
{/literal}{else if $step == 2}{literal}
// carrier
ga('ec:setAction','checkout', {
'step': 3,
});
{/literal}{else if $step == 3}{literal}
// payment
ga('ec:setAction','checkout', {
'step': 4,
});
{/literal}{/if}
{/if}{literal}
{/literal}{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}{literal}
// send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation'
var re = new RegExp("([?&])(email=)[^&#]*", "g");
var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g");
var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g");
if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) {
// remove personal data from url before sending to GA
url = window.location.search.replace(re, '$1$2');
url = url.replace(re2, '$1$2');
url = url.replace(re3, '$1$2');
var page = window.location.pathname+url;
ga('send', 'pageview', page);
} else {
ga('send', 'pageview');
}
{/literal}{/if}{literal}
function onStepComplete(stepNumber, option, redirect, form) {
ga('ec:setAction', 'checkout_option', {
'step': stepNumber,
'option': option
});
if (redirect != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
document.location = redirect;
}
});
} else if (form != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
form.submit();
}
});
} else {
ga('send', 'event', 'Checkout', 'Option', {});
}
}
function addToCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart');
}
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
}
</script>
{/literal}
{/if}
<!-- Facebook Pixel Code -->
{if $cookie->id_lang == 2}
{literal}
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '585280634957856');
fbq('track', "PageView");
</script>
{/literal}
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=585280634957856&amp;ev=PageView&amp;noscript=1"/></noscript>
{elseif $cookie->id_lang == 3}
{literal}
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '778018572325168');
fbq('track', "PageView");
</script>
{/literal}
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=778018572325168&amp;ev=PageView&amp;noscript=1"/></noscript>
{/if}
{literal}
<script>
fbq('track', 'ViewContent', {
content_name:'{/literal}{$page_name|escape:'html':'UTF-8'}{literal}'
}); });
</script> </script>
{/literal} {/literal}
{if isset($facebook_validation) && $facebook_validation} {/if}
{literal} {/if}
<script> <!-- End Facebook Pixel Code -->
fbq('track', 'CompleteRegistration');
</script> <!-- crazyegg -->
{/literal} {literal}
{/if} <script type="text/javascript">
setTimeout(function(){var a=document.createElement("script");
{if isset($page_name)} var b=document.getElementsByTagName("script")[0];
{if $page_name == 'order-confirmation' && isset($order)} a.src=document.location.protocol+"//script.crazyegg.com/pages/scripts/0047/9841.js?"+Math.floor(new Date().getTime()/3600000);
{literal} a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
<script> </script>
fbq('track', 'Purchase', { {/literal}
value: '{/literal}{$order->total_paid}{literal}',
currency: "{/literal}{$currencyIsoCode}{literal}"
});
</script>
{/literal}
{/if}
{/if}
<!-- End Facebook Pixel Code -->
<!-- crazyegg -->
{literal}
<script type="text/javascript">
setTimeout(function(){var a=document.createElement("script");
var b=document.getElementsByTagName("script")[0];
a.src=document.location.protocol+"//script.crazyegg.com/pages/scripts/0047/9841.js?"+Math.floor(new Date().getTime()/3600000);
a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
</script>
{/literal}
</head> </head>
<body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if} class="{$bodyClass}{if $cookie->isLogged()} logged{/if}{if isset($smarty.get.content_only)} content_only{/if}{if isset($smarty.post.email_create) || isset($smarty.get.create_account)} create{/if} lang{$cookie->id_lang}"> <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if} class="{$bodyClass}{if $cookie->isLogged()} logged{/if}{if isset($smarty.get.content_only)} content_only{/if}{if isset($smarty.post.email_create) || isset($smarty.get.create_account)} create{/if} lang{$cookie->id_lang}">
<!-- Google Tag Manager (noscript) --> <!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PT7ZGQF" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PT7ZGQF"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) --> <!-- End Google Tag Manager (noscript) -->
{if !$content_only} {if !$content_only}

View File

@ -79,372 +79,398 @@
<!-- Google Tag Manager --> <!-- Google Tag Manager -->
{literal} {literal}
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PT7ZGQF');</script> })(window,document,'script','dataLayer','GTM-PT7ZGQF');</script>
{/literal} {/literal}
<!-- End Google Tag Manager --> <!-- End Google Tag Manager -->
{assign var='isEC' value=Configuration::get('GANALYTICS_EC')} {assign var='isEC' value=Configuration::get('GANALYTICS_EC')}
{if $cookie->id_lang == 2} {if $cookie->id_lang == 2}
{literal}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-30665119-1', 'auto');
{/literal}{if isset($page_name) && $page_name == 'category'}{literal}
ga('require', 'ec');
{/literal}{else if isset($page_name) && $page_name == 'product'}{literal}
ga('require', 'ec');
ga('ec:addProduct', {
'id': {/literal}{$product->id}{literal},
'name': "{/literal}{$product->name|escape:'htmlall':'UTF-8'}{literal}",
'category': "{/literal}{$sale->title[$cookie->id_lang]}{literal}"
});
ga('ec:setAction', 'detail');
{/literal}{else if isset($page_name) && $page_name == 'order'}{literal}
ga('require', 'ec');
{/literal}
{if $step == 0 || $step == 1}
{if $cart}
{assign var='cartProducts' value=$cart->getProducts()}
{foreach from=$cartProducts item=cartProduct}
{literal}
ga('ec:addProduct', {
'id': {/literal}{$cartProduct['id_product']}{literal},
'name': "{/literal}{$cartProduct['name']}{literal}",
'category': "{/literal}{$cartProduct['category']}{literal}",
'price': {/literal}{Tools::ps_round(Product::getPriceStatic((int)$cartProduct['id_product'], true, ((isset($cartProduct['id_product_attribute']) AND !empty($cartProduct['id_product_attribute'])) ? (int)($cartProduct['id_product_attribute']) : NULL), 2), 2)}{literal},
'quantity': {/literal}{$cartProduct['cart_quantity']}{literal}
});
{/literal}
{/foreach}
{/if}
{/if}
{literal}
{/literal}{if $step == 0}{literal}
//cart
ga('ec:setAction','checkout', {
'step': 1,
});
{/literal}{else if $step == 1}{literal}
// address
ga('ec:setAction','checkout', {
'step': 2,
});
{/literal}{else if $step == 2}{literal}
// carrier
ga('ec:setAction','checkout', {
'step': 3,
});
{/literal}{else if $step == 3}{literal}
// payment
ga('ec:setAction','checkout', {
'step': 4,
});
{/literal}{/if}
{/if}{literal}
{/literal}{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}{literal}
// send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation'
var re = new RegExp("([?&])(email=)[^&#]*", "g");
var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g");
var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g");
if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) {
// remove personal data from url before sending to GA
url = window.location.search.replace(re, '$1$2');
url = url.replace(re2, '$1$2');
url = url.replace(re3, '$1$2');
var page = window.location.pathname+url;
ga('send', 'pageview', page);
} else {
ga('send', 'pageview');
}
{/literal}{/if}{literal}
function onStepComplete(stepNumber, option, redirect, form) {
ga('ec:setAction', 'checkout_option', {
'step': stepNumber,
'option': option
});
if (redirect != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
document.location = redirect;
}
});
} else if (form != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
form.submit();
}
});
} else {
ga('send', 'event', 'Checkout', 'Option', {});
}
}
function addToCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart');
}
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
}
</script>
{/literal}
{elseif $cookie->id_lang == 3}
{literal}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-68580471-1', 'auto');
{/literal}{if isset($page_name) && $page_name == 'category'}{literal}
ga('require', 'ec');
{/literal}{else if isset($page_name) && $page_name == 'product'}{literal}
ga('require', 'ec');
ga('ec:addProduct', {
'id': {/literal}{$product->id}{literal},
'name': "{/literal}{$product->name|escape:'htmlall':'UTF-8'}{literal}",
'category': "{/literal}{$sale->title[$cookie->id_lang]}{literal}"
});
ga('ec:setAction', 'detail');
{/literal}{else if isset($page_name) && $page_name == 'order'}{literal}
ga('require', 'ec');
{/literal}
{if $step == 0 || $step == 1}
{if $cart}
{assign var='cartProducts' value=$cart->getProducts()}
{foreach from=$cartProducts item=cartProduct}
{literal}
ga('ec:addProduct', {
'id': {/literal}{$cartProduct['id_product']}{literal},
'name': "{/literal}{$cartProduct['name']}{literal}",
'category': "{/literal}{$cartProduct['category']}{literal}",
'price': {/literal}{Tools::ps_round(Product::getPriceStatic((int)$cartProduct['id_product'], true, ((isset($cartProduct['id_product_attribute']) AND !empty($cartProduct['id_product_attribute'])) ? (int)($cartProduct['id_product_attribute']) : NULL), 2), 2)}{literal},
'quantity': {/literal}{$cartProduct['cart_quantity']}{literal}
});
{/literal}
{/foreach}
{/if}
{/if}
{literal}
{/literal}{if $step == 0}{literal}
//cart
ga('ec:setAction','checkout', {
'step': 1,
});
{/literal}{else if $step == 1}{literal}
// address
ga('ec:setAction','checkout', {
'step': 2,
});
{/literal}{else if $step == 2}{literal}
// carrier
ga('ec:setAction','checkout', {
'step': 3,
});
{/literal}{else if $step == 3}{literal}
// payment
ga('ec:setAction','checkout', {
'step': 4,
});
{/literal}{/if}
{/if}{literal}
{/literal}{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}{literal}
// send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation'
var re = new RegExp("([?&])(email=)[^&#]*", "g");
var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g");
var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g");
if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) {
// remove personal data from url before sending to GA
url = window.location.search.replace(re, '$1$2');
url = url.replace(re2, '$1$2');
url = url.replace(re3, '$1$2');
var page = window.location.pathname+url;
ga('send', 'pageview', page);
} else {
ga('send', 'pageview');
}
{/literal}{/if}{literal}
function onStepComplete(stepNumber, option, redirect, form) {
ga('ec:setAction', 'checkout_option', {
'step': stepNumber,
'option': option
});
if (redirect != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
document.location = redirect;
}
});
} else if (form != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
form.submit();
}
});
} else {
ga('send', 'event', 'Checkout', 'Option', {});
}
}
function addToCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart');
}
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
}
</script>
{/literal}
{/if}
<!-- Facebook Pixel Code -->
{if $cookie->id_lang == 2}
{literal}
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '585280634957856');
fbq('track', "PageView");
</script>
{/literal}
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=585280634957856&amp;ev=PageView&amp;noscript=1"/></noscript>
{elseif $cookie->id_lang == 3}
{literal}
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '778018572325168');
fbq('track', "PageView");
</script>
{/literal}
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=778018572325168&amp;ev=PageView&amp;noscript=1"/></noscript>
{/if}
{literal} {literal}
<script> <script>
fbq('track', 'ViewContent', { (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
content_name:'{/literal}{$page_name|escape:'html':'UTF-8'}{literal}' (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-30665119-1', 'auto');
{/literal}
{if isset($page_name) && $page_name == 'category'}
{literal}
ga('require', 'ec');
{/literal}
{else if isset($page_name) && $page_name == 'product'}
{literal}
ga('require', 'ec');
ga('ec:addProduct', {
'id': {/literal}{$product->id}{literal},
'name': "{/literal}{$product->name|escape:'htmlall':'UTF-8'}{literal}",
'category': "{/literal}{$sale->title[$cookie->id_lang]}{literal}"
}); });
ga('ec:setAction', 'detail');
{/literal}
{else if isset($page_name) && $page_name == 'order'}
{literal}
ga('require', 'ec');
{/literal}
{if $step == 0 || $step == 1}
{if $cart}
{assign var='cartProducts' value=$cart->getProducts()}
{foreach from=$cartProducts item=cartProduct}
{literal}
ga('ec:addProduct', {
'id': {/literal}{$cartProduct['id_product']}{literal},
'name': "{/literal}{$cartProduct['name']}{literal}",
'category': "{/literal}{$cartProduct['category']}{literal}",
'price': {/literal}{Tools::ps_round(Product::getPriceStatic((int)$cartProduct['id_product'], true, ((isset($cartProduct['id_product_attribute']) AND !empty($cartProduct['id_product_attribute'])) ? (int)($cartProduct['id_product_attribute']) : NULL), 2), 2)}{literal},
'quantity': {/literal}{$cartProduct['cart_quantity']}{literal}
});
{/literal}
{/foreach}
{/if}
{/if}
{literal}
{/literal}
{if $step == 0}{literal}
//cart
ga('ec:setAction','checkout', {
'step': 1,
});
{/literal}
{else if $step == 1}{literal}
// address
ga('ec:setAction','checkout', {
'step': 2,
});
{/literal}
{else if $step == 2}{literal}
// carrier
ga('ec:setAction','checkout', {
'step': 3,
});
{/literal}
{else if $step == 3}{literal}
// payment
ga('ec:setAction','checkout', {
'step': 4,
});
{/literal}
{/if}
{/if}
{literal}
{/literal}
{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}
{literal}
// send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation'
var re = new RegExp("([?&])(email=)[^&#]*", "g");
var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g");
var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g");
if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) {
// remove personal data from url before sending to GA
url = window.location.search.replace(re, '$1$2');
url = url.replace(re2, '$1$2');
url = url.replace(re3, '$1$2');
var page = window.location.pathname+url;
ga('send', 'pageview', page);
} else {
ga('send', 'pageview');
}
{/literal}
{/if}
{literal}
function onStepComplete(stepNumber, option, redirect, form) {
ga('ec:setAction', 'checkout_option', {
'step': stepNumber,
'option': option
});
if (redirect != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
document.location = redirect;
}
});
} else if (form != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
form.submit();
}
});
} else {
ga('send', 'event', 'Checkout', 'Option', {});
}
}
function addToCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart');
}
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
}
</script> </script>
{/literal} {/literal}
{elseif $cookie->id_lang == 3}
{literal}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
{if isset($facebook_validation) && $facebook_validation} ga('create', 'UA-68580471-1', 'auto');
{/literal}
{if isset($page_name) && $page_name == 'category'}
{literal}
ga('require', 'ec');
{/literal}
{else if isset($page_name) && $page_name == 'product'}
{literal}
ga('require', 'ec');
ga('ec:addProduct', {
'id': {/literal}{$product->id}{literal},
'name': "{/literal}{$product->name|escape:'htmlall':'UTF-8'}{literal}",
'category': "{/literal}{$sale->title[$cookie->id_lang]}{literal}"
});
ga('ec:setAction', 'detail');
{/literal}
{else if isset($page_name) && $page_name == 'order'}
{literal}
ga('require', 'ec');
{/literal}
{if $step == 0 || $step == 1}
{if $cart}
{assign var='cartProducts' value=$cart->getProducts()}
{foreach from=$cartProducts item=cartProduct}
{literal}
ga('ec:addProduct', {
'id': {/literal}{$cartProduct['id_product']}{literal},
'name': "{/literal}{$cartProduct['name']}{literal}",
'category': "{/literal}{$cartProduct['category']}{literal}",
'price': {/literal}{Tools::ps_round(Product::getPriceStatic((int)$cartProduct['id_product'], true, ((isset($cartProduct['id_product_attribute']) AND !empty($cartProduct['id_product_attribute'])) ? (int)($cartProduct['id_product_attribute']) : NULL), 2), 2)}{literal},
'quantity': {/literal}{$cartProduct['cart_quantity']}{literal}
});
{/literal}
{/foreach}
{/if}
{/if}
{literal}
{/literal}
{if $step == 0}
{literal}
//cart
ga('ec:setAction','checkout', {
'step': 1,
});
{/literal}
{else if $step == 1}
{literal}
// address
ga('ec:setAction','checkout', {
'step': 2,
});
{/literal}
{else if $step == 2}
{literal}
// carrier
ga('ec:setAction','checkout', {
'step': 3,
});
{/literal}
else if $step == 3}
{literal}
// payment
ga('ec:setAction','checkout', {
'step': 4,
});
{/literal}
{/if}
{/if}
{literal}
{/literal}
{if isset($page_name) && (($page_name == 'order-confirmation' && $isEC==0) || $page_name != 'order-confirmation')}
{literal}
// send pageview via header.tpl du module GA si isEC=1 and $page_name == 'order-confirmation'
var re = new RegExp("([?&])(email=)[^&#]*", "g");
var re2 = new RegExp("([?&])(customer_lastname=)[^&#]*", "g");
var re3 = new RegExp("([?&])(customer_firstname=)[^&#]*", "g");
if (document.location.href.match(re) || document.location.href.match(re2) || document.location.href.match(re3)) {
// remove personal data from url before sending to GA
url = window.location.search.replace(re, '$1$2');
url = url.replace(re2, '$1$2');
url = url.replace(re3, '$1$2');
var page = window.location.pathname+url;
ga('send', 'pageview', page);
} else {
ga('send', 'pageview');
}
{/literal}
{/if}
{literal}
function onStepComplete(stepNumber, option, redirect, form) {
ga('ec:setAction', 'checkout_option', {
'step': stepNumber,
'option': option
});
if (redirect != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
document.location = redirect;
}
});
} else if (form != null) {
ga('send', 'event', 'Checkout', 'Option', {
hitCallback: function() {
form.submit();
}
});
} else {
ga('send', 'event', 'Checkout', 'Option', {});
}
}
function addToCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart');
}
function removeFromCartToGA(product) {
ga('ec:addProduct', {
'id': product.id,
'name': product.name,
'brand': product.category,
'category': product.category,
'variant' : product.variant,
'price': product.price,
'quantity': product.qty
});
ga('ec:setAction', 'remove');
ga('send', 'event', 'UX', 'click', 'remove to cart');
}
</script>
{/literal}
{/if}
<!-- Facebook Pixel Code -->
{if $cookie->id_lang == 2}
{literal}
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '585280634957856');
fbq('track', "PageView");
</script>
{/literal}
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=585280634957856&amp;ev=PageView&amp;noscript=1"/></noscript>
{elseif $cookie->id_lang == 3}
{literal}
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '778018572325168');
fbq('track', "PageView");
</script>
{/literal}
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=778018572325168&amp;ev=PageView&amp;noscript=1"/></noscript>
{/if}
{literal}
<script>
fbq('track', 'ViewContent', {
content_name:'{/literal}{$page_name|escape:'html':'UTF-8'}{literal}'
});
</script>
{/literal}
{if isset($facebook_validation) && $facebook_validation}
{literal}
<script>
fbq('track', 'CompleteRegistration');
</script>
{/literal}
{/if}
{if isset($page_name)}
{if $page_name == 'order-confirmation'}
{literal} {literal}
<script> <script>
fbq('track', 'CompleteRegistration'); fbq('track', 'Purchase', {
value: '{/literal}{$order->total_paid}{literal}',
currency: "{/literal}{$currency['iso_code']}{literal}"
});
</script> </script>
{/literal} {/literal}
{/if} {/if}
{/if}
<!-- End Facebook Pixel Code -->
{if isset($page_name)} <!-- crazyegg -->
{if $page_name == 'order-confirmation'} {literal}
{literal} <script type="text/javascript">
<script> setTimeout(function(){var a=document.createElement("script");
fbq('track', 'Purchase', { var b=document.getElementsByTagName("script")[0];
value: '{/literal}{$order->total_paid}{literal}', a.src=document.location.protocol+"//script.crazyegg.com/pages/scripts/0047/9841.js?"+Math.floor(new Date().getTime()/3600000);
currency: "{/literal}{$currencyIsoCode}{literal}" a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
}); </script>
</script> {/literal}
{/literal}
{/if} {include file="$tpl_dir./header-meta-fb.tpl"}
{/if}
<!-- End Facebook Pixel Code -->
<!-- crazyegg -->
{literal}
<script type="text/javascript">
setTimeout(function(){var a=document.createElement("script");
var b=document.getElementsByTagName("script")[0];
a.src=document.location.protocol+"//script.crazyegg.com/pages/scripts/0047/9841.js?"+Math.floor(new Date().getTime()/3600000);
a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
</script>
{/literal}
{include file="$tpl_dir./header-meta-fb.tpl"}
</head> </head>
<body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if} class="{$bodyClass}{if $cookie->isLogged()} logged{/if}"> <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if} class="{$bodyClass}{if $cookie->isLogged()} logged{/if}">
<!--[if lte IE 6]> <!-- Google Tag Manager (noscript) -->
<div id="ie_notification" style="background: #FFFFE1; border-bottom: 1px solid #A0A0A0; padding: 10px;line-height: 1.4em; text-align: justify;"> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PT7ZGQF"
<strong>{l s='Warning, you are currently using an obsolete browser.'}</strong> height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
{l s='It is a potential source of security breaches and may not display this website properly. Please update your browser to'} <a style="text-decoration: underline;" href="http://windows.microsoft.com/{$lang_iso}-{$lang_iso|strtoupper}/internet-explorer/downloads/ie" onclick="window.open(this.href); return false;">Microsoft Internet Explorer 8</a>. <!-- End Google Tag Manager (noscript) -->
{l s='You can also use an alternative browser, such as'} <a style="text-decoration: underline;" href="http://mozilla-europe.org/{$lang_iso}/" onclick="window.open(this.href); return false;">Mozilla Firefox</a>, <a style="text-decoration: underline;" href="http://www.opera.com/" onclick="window.open(this.href); return false;">Opera</a>, <a style="text-decoration: underline;" href="http://www.google.com/chrome" onclick="window.open(this.href); return false;">Google Chrome</a> {l s='or'} <a style="text-decoration: underline;" href="http://www.apple.com/{$lang_iso}/safari/" onclick="window.open(this.href); return false;">Safari</a>.
{l s='These softwares are free. If you don\'t have administrative rights on your computer to install programs, please contact your system administrator.'}
</div>
<![endif]-->
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PT7ZGQF" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
{if !$content_only} {if !$content_only}
{if isset($restricted_country_mode) && $restricted_country_mode} {if isset($restricted_country_mode) && $restricted_country_mode}