Merge branch 'ticket-GAnalytics' into develop

This commit is contained in:
Marion Muszynski 2016-09-20 18:00:48 +02:00
commit 9673ff3805
3 changed files with 278 additions and 217 deletions

View File

@ -26,225 +26,258 @@
<!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}">
<head>
<title>{$meta_title|escape:'htmlall':'UTF-8'}</title>
<head>
<title>{$meta_title|escape:'htmlall':'UTF-8'}</title>
{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 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 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}
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<meta name="robots" content="{if isset($nobots)}no{/if}index,follow" />
<link rel="icon" type="image/png" href="{$img_ps_dir}preview.png?{$img_update_time}" />
<link rel="icon" type="image/vnd.microsoft.icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" />
<link rel="shortcut icon" type="image/x-icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" />
{if isset($page_name) && $page_name == 'authentication'}
<link rel="canonical" href="{$link->getPageLink('authentication.php', TRUE)}" />
{/if}
<script type="text/javascript">
var baseDir = '{$content_dir}';
var static_token = '{$static_token}';
var token = '{$token}';
var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals};
var priceDisplayMethod = {$priceDisplay};
var roundMode = {$roundMode};
var isoLang = "{$lang_iso}";
</script>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<meta name="robots" content="{if isset($nobots)}no{/if}index,follow" />
<link rel="icon" type="image/png" href="{$img_ps_dir}preview.png?{$img_update_time}" />
<link rel="icon" type="image/vnd.microsoft.icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" />
<link rel="shortcut icon" type="image/x-icon" href="{$img_ps_dir}favicon.ico?{$img_update_time}" />
{if isset($page_name) && $page_name == 'authentication'}
<link rel="canonical" href="{$link->getPageLink('authentication.php', TRUE)}" />
{/if}
<script type="text/javascript">
var baseDir = '{$content_dir}';
var static_token = '{$static_token}';
var token = '{$token}';
var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals};
var priceDisplayMethod = {$priceDisplay};
var roundMode = {$roundMode};
var isoLang = "{$lang_iso}";
</script>
{if isset($css_files)}
{foreach from=$css_files key=css_uri item=media}
<link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" />
{/foreach}
{foreach from=$css_files key=css_uri item=media}
<link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" />
{/foreach}
{/if}
{if isset($js_files)}
{foreach from=$js_files item=js_uri}
<script type="text/javascript" src="{$js_uri}"></script>
{/foreach}
{foreach from=$js_files item=js_uri}
<script type="text/javascript" src="{$js_uri}"></script>
{/foreach}
{/if}
<link rel="apple-touch-icon" href="{$base_dir_ssl}img/apple-touch-icon.png" />
{$HOOK_HEADER}
<!--[if IE 7]>
<link href="{$css_dir}ie7.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<!--[if IE 8]>
<link href="{$css_dir}ie8.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<!--[if IE 9]>
<link href="{$css_dir}ie9.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<link rel="apple-touch-icon" href="{$base_dir_ssl}img/apple-touch-icon.png" />
{$HOOK_HEADER}
<!--[if IE 7]>
<link href="{$css_dir}ie7.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<!--[if IE 8]>
<link href="{$css_dir}ie8.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<!--[if IE 9]>
<link href="{$css_dir}ie9.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
{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');
{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');
ga('create', 'UA-30665119-1', 'auto');
{/literal}{if isset($page_name) && $page_name == 'order'}{literal}
ga('require', 'ec');
{/literal}{if isset($page_name) && $page_name == 'order'}{literal}
ga('require', 'ec');
{/literal}{if $step == 0}{literal}
{/literal}{if $cart}
{assign var='cartProducts' value=$cart->getProducts()}{literal}
{/literal}{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}{literal}
{/literal}{/if}{literal}
ga('ec:setAction','checkout', {
'step': 1,
});
{/literal}{else if $step == 1}{literal}
ga('ec:setAction','checkout', {
'step': 2,
});
{/literal}{else if $step == 2}{literal}
ga('ec:setAction','checkout', {
'step': 3,
});
{/literal}{else if $step == 3}{literal}
ga('ec:setAction','checkout', {
'step': 4,
});
{/literal}{/if}
{/if}{literal}
{/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}
ga('send', 'pageview');
</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 $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}
ga('create', 'UA-68580471-1', 'auto');
ga('send', 'pageview');
</script>
{/literal}
{/if}
ga('send', 'pageview');
<!-- 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');
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', {});
}
}
</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');
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');
ga('create', 'UA-68580471-1', 'auto');
ga('send', 'pageview');
</script>
{/literal}
{/if}
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}
<!-- 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');
{literal}
<script>
fbq('track', 'ViewContent', {
content_name:'{/literal}{$page_name|escape:'html':'UTF-8'}{literal}'
});
</script>
{/literal}
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');
{if isset($smarty.get.validation)}
{literal}
<script>
fbq('track', 'CompleteRegistration');
</script>
{/literal}
{/if}
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}
{if isset($page_name)}
{if $page_name == 'order-confirmation' && isset($order)}
{literal}
<script>
fbq('track', 'Purchase', {
value: '{/literal}{$order->total_paid}{literal}',
currency: "{/literal}{$currency['name']}{literal}"
});
</script>
{/literal}
{/if}
{/if}
<!-- End Facebook Pixel Code -->
{literal}
<script>
fbq('track', 'ViewContent', {
content_name:'{/literal}{$page_name|escape:'html':'UTF-8'}{literal}'
});
</script>
{/literal}
<!-- 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}
{if isset($smarty.get.validation)}
{literal}
<script>
fbq('track', 'CompleteRegistration');
</script>
{/literal}
{/if}
</head>
{if isset($page_name)}
{if $page_name == 'order-confirmation' && isset($order)}
{literal}
<script>
fbq('track', 'Purchase', {
value: '{/literal}{$order->total_paid}{literal}',
currency: "{/literal}{$currency['name']}{literal}"
});
</script>
{/literal}
{/if}
{/if}
<!-- End Facebook Pixel Code -->
<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}">
<!-- 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}
{if !$content_only}
{if isset($restricted_country_mode) && $restricted_country_mode}
<div id="restricted-country">
<p>{l s='You cannot place a new order from your country.'} <span class="bold">{$geolocation_country}</span></p>
</div>
{/if}
<div id="page">
</head>
<!-- Header -->
<div id="header">
<div class="content">
<div class="top">
<div class="content">
<span class='help_contact'><a href="{$link->getCMSLink(14)}">{l s='Aide et contact'}</a></span>
{$HOOK_TOP}
</div>
</div>
</div>
{$HOOK_TOP_MENU}
</div>
<div id="subheader"></div>
<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}">
<div id="columns">
<div class="content">
{if isset($SKINSTATIC_COLUMNS)}{$SKINSTATIC_COLUMNS}{/if}
{if !$content_only}
{if isset($restricted_country_mode) && $restricted_country_mode}
<div id="restricted-country">
<p>{l s='You cannot place a new order from your country.'} <span class="bold">{$geolocation_country}</span></p>
</div>
{/if}
<div id="page">
{if in_array($page_name, $displayLeft)}
<!-- Left -->
<div id="left_column" class="column">
{$HOOK_LEFT_COLUMN}
</div>
{/if}
<!-- Header -->
<div id="header">
<div class="content">
<div class="top">
<div class="content">
<span class='help_contact'><a href="{$link->getCMSLink(14)}">{l s='Aide et contact'}</a></span>
{$HOOK_TOP}
</div>
</div>
</div>
{$HOOK_TOP_MENU}
</div>
<div id="subheader"></div>
<!-- Center -->
<div id="center_column">
{/if}
<div id="columns">
<div class="content">
{if isset($SKINSTATIC_COLUMNS)}{$SKINSTATIC_COLUMNS}{/if}
{if in_array($page_name, $displayLeft)}
<!-- Left -->
<div id="left_column" class="column">
{$HOOK_LEFT_COLUMN}
</div>
{/if}
<!-- Center -->
<div id="center_column">
{/if}

View File

@ -37,6 +37,16 @@
var msg = "{l s='You must agree to the terms of service before continuing.' js=1}";
{literal}
function submitCarrier() {
var cgv = acceptCGV();
if(cgv) {
// carrier = $("input[name='id_carrier']:checked","#form").val();
carrier_name = ""+$("input[name='id_carrier']:checked", "#form").data('name')+"";
onStepComplete(3, carrier_name, null, null);
} else {
return cgv;
}
}
function acceptCGV()
{
if ($('#cgv').length && !$('input#cgv:checked').length)
@ -82,7 +92,7 @@
{include file="$tpl_dir./errors.tpl"}
<form id="form" action="{$link->getPageLink('order.php', true)}" method="post" onsubmit="return acceptCGV();">
<form id="form" action="{$link->getPageLink('order.php', true)}" method="post" onsubmit="return submitCarrier();return !ga.loaded;">
{else}
<h2>2. {l s='Delivery methods'}</h2>
<div id="opc_delivery_methods" class="opc-main-block">
@ -128,7 +138,7 @@
{foreach from=$carriers item=carrier name=myLoop}
<tr class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{/if} {if $smarty.foreach.myLoop.index % 2}alternate_item{else}item{/if}">
<td class="carrier_action radio">
<input type="radio" name="id_carrier" value="{$carrier.id_carrier|intval}" id="id_carrier{$carrier.id_carrier|intval}" {if $opc}onclick="updateCarrierSelectionAndGift();"{/if} {if !($carrier.is_module AND $opc AND !$isLogged)}{if $carrier.id_carrier == $checked}checked="checked"{/if}{else}disabled="disabled"{/if} />
<input type="radio" name="id_carrier" value="{$carrier.id_carrier|intval}" data-name="{$carrier.name|escape:'htmlall':'UTF-8'}" id="id_carrier{$carrier.id_carrier|intval}" {if $opc}onclick="updateCarrierSelectionAndGift();"{/if} {if !($carrier.is_module AND $opc AND !$isLogged)}{if $carrier.id_carrier == $checked}checked="checked"{/if}{else}disabled="disabled"{/if} />
</td>
<td class="carrier_name">
<label for="id_carrier{$carrier.id_carrier|intval}">

View File

@ -34,6 +34,25 @@
var txtProduct = "{l s='product'}";
var txtProducts = "{l s='products'}";
// ]]>
function submitPayment(){
$input = $('input[name="paiement-method"]:checked');
if(!$input.length) {
alert(paiementErrorMessage);
}
if ($input.val()) {
// redirect for GA send event
onStepComplete(4, $input.attr('data-module-name') ,$input.val(),null);
} else {
// LOADER POUR PAYPAL
if ($input.attr('data-module-name') == "paypal") {
$('.overlay_bbb').fadeIn();
$('.box_paypal').fadeIn();
}
$form = $input.parent().children('div.hidden').children('form');
// submit form for GA send event
onStepComplete(4, $input.attr('data-module-name'),null,$form);
}
}
</script>
{capture name=path}{l s='Your payment method'}{/capture}
@ -72,7 +91,7 @@
{/if}
<p class="cart_navigation">
<a href="{$link->getPageLink('order.php', true)}?step=2" title="{l s='Previous'}" class="button">{l s='Previous'}</a>
<a class="exclusive submitPayment" title="{l s='Valider ma commande'}" class="button">{l s='Valider ma commande'}</a>
<a class="exclusive submitPayment" title="{l s='Valider ma commande'}" class="button" onclick="submitPayment(); return !ga.loaded;">{l s='Valider ma commande'}</a>
</p>
{else}
</div>
@ -93,37 +112,36 @@
</div>
<script>
<script>
var paiementErrorMessage = "{l s='You have to choose a paiement method' js=1}";
</script>
{literal}
<script>
$(document).ready(function() {
$('.payment_module .inner').live('click', function(e) {
$('.payment_module .inner').live('click', function(e) {
$(this).children('.input_radio').children('input[name="paiement-method"]').attr('checked', true);
});
$('.submitPayment').live('click', function(e) {
e.preventDefault();
// check if selected
$input = $('input[name="paiement-method"]:checked');
if(!$input.length) {
alert(paiementErrorMessage);
}
if ($input.val()) {
window.location = $input.val();
} else {
// LOADER POUR PAYPAL
if ($input.attr('data-module-name') == "paypal") {
$('.overlay_bbb').fadeIn();
$('.box_paypal').fadeIn();
}
$form = $input.parent().children('div.hidden').children('form');
$form.submit();
}
// $('.submitPayment').live('click', function(e) {
// e.preventDefault();
// // check if selected
// $input = $('input[name="paiement-method"]:checked');
// if(!$input.length) {
// alert(paiementErrorMessage);
// }
// if ($input.val()) {
// window.location = $input.val();
// } else {
// // LOADER POUR PAYPAL
// if ($input.attr('data-module-name') == "paypal") {
// $('.overlay_bbb').fadeIn();
// $('.box_paypal').fadeIn();
// }
// $form = $input.parent().children('div.hidden').children('form');
// $form.submit();
// }
});
// });
});
</script>