Merge branch 'ticket-GAnalytics-mobile' into develop
This commit is contained in:
commit
c7579d79aa
@ -650,7 +650,9 @@ function confirmation(idProduct, idCombination, quantity, json) {
|
||||
$('.overlay_bbb').fadeIn();
|
||||
$('.box_add_to_cart').fadeIn();
|
||||
// send add product to cart information to GA
|
||||
addToCartToGA(productToGA);
|
||||
if (window.ga && ga.create){
|
||||
addToCartToGA(productToGA);
|
||||
}
|
||||
}
|
||||
// AJOUT PANIER ACHAT EXPRESS
|
||||
else{
|
||||
@ -666,7 +668,9 @@ function confirmation(idProduct, idCombination, quantity, json) {
|
||||
window.parent.$('.overlay_bbb').fadeIn();
|
||||
window.parent.$('.box_add_to_cart').fadeIn();
|
||||
// send add product to cart information to GA
|
||||
window.parent.addToCartToGA(productToGA);
|
||||
if (window.parent.ga && window.parent.ga.create){
|
||||
window.parent.addToCartToGA(productToGA);
|
||||
}
|
||||
},
|
||||
error: function() {alert('ERROR: unable to delete the product');}
|
||||
});
|
||||
|
@ -633,7 +633,9 @@
|
||||
"price" : prod_price.trim(),
|
||||
"qty" : quantity
|
||||
};
|
||||
window.parent.addToCartToGA(productToGA);
|
||||
if (window.parent.ga && window.parent.ga.create){
|
||||
window.parent.addToCartToGA(productToGA);
|
||||
}
|
||||
|
||||
$('.product_added_to_cart').show();
|
||||
setTimeout(function() {
|
||||
|
@ -92,7 +92,101 @@
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-30665119-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
{/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'
|
||||
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,
|
||||
'variant' : product.variant,
|
||||
'price': product.price,
|
||||
'quantity': product.qty
|
||||
});
|
||||
ga('ec:setAction', 'add');
|
||||
ga('send', 'event', 'UX', 'click', 'add to cart');
|
||||
}
|
||||
</script>
|
||||
{/literal}
|
||||
{elseif $cookie->id_lang == 3}
|
||||
@ -104,11 +198,105 @@
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-68580471-1', 'auto');
|
||||
ga('send', 'pageview');
|
||||
{/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'
|
||||
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,
|
||||
'variant' : product.variant,
|
||||
'price': product.price,
|
||||
'quantity': product.qty
|
||||
});
|
||||
ga('ec:setAction', 'add');
|
||||
ga('send', 'event', 'UX', 'click', 'add to cart');
|
||||
}
|
||||
</script>
|
||||
{/literal}
|
||||
{/if}
|
||||
|
||||
|
||||
<!-- Facebook Pixel Code -->
|
||||
{if $cookie->id_lang == 2}
|
||||
{literal}
|
||||
@ -147,7 +335,7 @@
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
|
||||
{if isset($smarty.get.validation)}
|
||||
{literal}
|
||||
<script>
|
||||
|
@ -28,7 +28,7 @@
|
||||
<div class="inner">
|
||||
<div class="input_radio">
|
||||
<div class="hidden">
|
||||
<form id="paypal_payment_form" action="{$base_dir_ssl}modules/paypal/express_checkout/payment.php" data-ajax="false" title="{l s='Pay with PayPal' mod='paypal'}" method="post">
|
||||
<form data-module-name="paypal" id="paypal_payment_form" action="{$base_dir_ssl}modules/paypal/express_checkout/payment.php" data-ajax="false" title="{l s='Pay with PayPal' mod='paypal'}" method="post">
|
||||
<input type="hidden" name="save_billing" id="save_billing_paypal" value="0"/>
|
||||
<input type="hidden" name="express_checkout" value="{$PayPal_payment_type|escape:'htmlall':'UTF-8'}"/>
|
||||
<input type="hidden" name="current_shop_url" value="{$PayPal_current_page|escape:'htmlall':'UTF-8'}" />
|
||||
|
@ -37,6 +37,15 @@
|
||||
|
||||
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_name = ""+$("input[name='id_carrier']:checked", "#form").data('carrier-name')+"";
|
||||
onStepComplete(3, carrier_name, null, null);
|
||||
} else {
|
||||
return cgv;
|
||||
}
|
||||
}
|
||||
function acceptCGV()
|
||||
{
|
||||
if ($('#cgv').length && !$('input#cgv:checked').length)
|
||||
@ -81,7 +90,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 ((window.ga && ga.create)? !ga.loaded : true);">
|
||||
{else}
|
||||
<h2>2. {l s='Delivery methods'}</h2>
|
||||
<div id="opc_delivery_methods" class="opc-main-block">
|
||||
@ -133,7 +142,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}" id="id_carrier{$carrier.id_carrier|intval}" data-carrier-name="{$carrier.name|escape:'htmlall':'UTF-8'}" {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}">
|
||||
@ -160,7 +169,7 @@
|
||||
{/if}
|
||||
{else}
|
||||
{l s='Free!'}
|
||||
{/if}
|
||||
{/if}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
@ -179,7 +188,7 @@
|
||||
{foreach from=$carriers_ooh 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}" id="id_carrier{$carrier.id_carrier|intval}" data-carrier-name="{$carrier.name|escape:'htmlall':'UTF-8'}" {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}">
|
||||
|
@ -34,6 +34,43 @@
|
||||
var txtProduct = "{l s='product'}";
|
||||
var txtProducts = "{l s='products'}";
|
||||
// ]]>
|
||||
{literal}
|
||||
// Function to submit payment and send the information to GA
|
||||
function submitPayment(){
|
||||
$input = $('input[name="paiement-method"]:checked');
|
||||
if(!$input.length) {
|
||||
alert(paiementErrorMessage);
|
||||
}
|
||||
if ($input.val()) {
|
||||
// LOADER POUR PAYBOX
|
||||
if ($input.attr('data-module-name') == "paybox-direct"){
|
||||
$('.overlay_bbb').fadeIn();
|
||||
$('.box_paybox').fadeIn();
|
||||
}
|
||||
if (window.ga && ga.create){
|
||||
// redirect by GA send event
|
||||
onStepComplete(4, $input.attr('data-module-name') ,$input.val(),null);
|
||||
} else {
|
||||
window.location = $input.val();
|
||||
}
|
||||
} else {
|
||||
$form = $input.parent().children('div.hidden').children('form');
|
||||
$name = $form.attr('data-module-name');
|
||||
// LOADER POUR PAYPAL
|
||||
if ($input.attr('data-module-name') == "paypal") {
|
||||
$('.overlay_bbb').fadeIn();
|
||||
$('.box_paypal').fadeIn();
|
||||
$name = 'paypal';
|
||||
}
|
||||
if (window.ga && ga.create){
|
||||
// submit form by GA send event
|
||||
onStepComplete(4, $name,null,$form);
|
||||
} else {
|
||||
$form.submit();
|
||||
}
|
||||
}
|
||||
}
|
||||
{/literal}
|
||||
</script>
|
||||
|
||||
{capture name=path}{l s='Your payment method'}{/capture}
|
||||
@ -66,7 +103,7 @@
|
||||
{if !$opc}
|
||||
<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 ((window.ga && ga.create)? !ga.loaded : true);">{l s='Valider ma commande'}</a>
|
||||
</p>
|
||||
{else}
|
||||
</div>
|
||||
@ -110,32 +147,30 @@
|
||||
$(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()) {
|
||||
// LOADER POUR PAYBOX
|
||||
if ($input.attr('data-module-name') == "paybox-direct"){
|
||||
$('.overlay_bbb').fadeIn();
|
||||
$('.box_paybox').fadeIn();
|
||||
}
|
||||
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()) {
|
||||
// // LOADER POUR PAYBOX
|
||||
// if ($input.attr('data-module-name') == "paybox-direct"){
|
||||
// $('.overlay_bbb').fadeIn();
|
||||
// $('.box_paybox').fadeIn();
|
||||
// }
|
||||
// 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>
|
||||
|
Loading…
Reference in New Issue
Block a user