{% set dataUserType = getTypeUserAndAboTagGoogle(app.user) %}
{% set sessionLivraisontag = getSessionLivraison() %}
{% set titlePage = titlePage %}
{% set categoryPage = categoryPage %}
{% if app.user %}
{% set user_login_status = 'logged in' %}
{% set user_type = dataUserType.user_type %}
{% set subscription_type = dataUserType.subscription_type %}
{% else %}
{% set user_login_status = 'logged out' %}
{% set user_type = dataUserType.user_type %}
{% set subscription_type = dataUserType.subscription_type %}
{% endif %}
<script>
titlePage = '{{ titlePage }}';
categoryPage = '{{ categoryPage }}';
dataLayer.push({
event: 'page_view',
event_group: 'pageviews',
delivery_adress: '{{ sessionLivraisontag.addresseAdresse }}',
user_login_status: '{{ user_login_status }}',
user_type: '{{ user_type }}',
subscription_type: '{{ subscription_type }}',
page_title: titlePage,
page_category: categoryPage,
});
</script>
{% if app.request.get('navigate') == 'navigated_from_menu' %}
<script>
dataLayer.push({
event: 'navigated_to',
event_group: 'navigation',
user_type:'{{ user_type }}',
user_login_status:'{{ user_login_status }}',
navigation_category1:'{{ navigation_category1 }}',
navigation_category2:'{{ navigation_category2 }}',
navigation_category3:'{{ navigation_category3 }}',
});
</script>
{% endif %}
{% if app.request.get('navigate') == 'navigated_from_footer' %}
<script>
dataLayer.push({
event: 'footer_navigated',
event_group: 'navigation',
user_type:'{{ user_type }}',
user_login_status:'{{ user_login_status }}',
link_clicked:'{{ app.request.get('link_clicked') }}',
});
</script>
{% endif %}
{% if app.request.get('navigate') == 'navigated_from_promotion' %}
<script>
dataLayer.push({
event: 'select_promotion',
event_group: 'promotion',
user_type:'{{ user_type }}',
user_login_status:'{{ user_login_status }}',
link_clicked:'{{ app.request.get('link_clicked') }}',
});
</script>
{% endif %}
{% if app.request.get('navigate') == 'navigated_from_business_offer' %}
<script>
dataLayer.push({
event: 'our_business',
event_group: 'business_offer',
user_type:'{{ user_type }}',
user_login_status:'{{ user_login_status }}',
link_clicked:'{{ app.request.get('link_clicked') }}',
});
</script>
{% endif %}
{% if app.request.get('navigate') == 'navigated_from_b2b_menu' %}
<script>
dataLayer.push({
event: 'navigated_to',
event_group: 'navigation_btob',
user_type:'{{ user_type }}',
user_login_status:'{{ user_login_status }}',
link_clicked:'{{ app.request.get('link_clicked') }}',
});
</script>
{% endif %}
{% if app.request.get('navigate') == 'navigated_from_header_menu' %}
<script>
dataLayer.push({
event: 'header_navigated',
event_group: 'navigation',
user_type:'{{ user_type }}',
user_login_status:'{{ user_login_status }}',
link_clicked:'{{ app.request.get('link_clicked') }}',
});
</script>
{% endif %}
<script>
var items = []
{% if cart is defined %}
{% if cart.cartDetail is defined %}
{% for detail in cart.cartDetail %}
var item = {}
{% if detail.product.isColorLab %}
{% if detail.productAttribute.typeFormat.id is defined %}
item.item_name = '{{ detail.product.titre~' '~detail.productAttribute.typeFormat.name }}';
{% else %}
item.item_name = '{{ detail.product.titre }}';
{% endif %}
{% else %}
{% if detail.productAttribute.format.id is defined %}
item.item_name = '{{ detail.product.titre~' '~detail.productAttribute.format.name }}';
{% else %}
item.item_name = '{{ detail.product.titre }}';
{% endif %}
{% endif %}
item.item_id = '{{ detail.product.id }}';
item.item_category = 'articles';
item.price = {{ detail.prixTtc }};
item.quantity = '{{ detail.nbrPapier + detail.qty }}';
{% if cart.isPromo and cart.codePromo.name is defined %}
item.coupon = '{{ cart.codePromo.name }}';
{% endif %}
items.push(item);
{% endfor %}
{% endif %}
{% if cart.abonnementProCart is defined and cart.abonnementProCart %}
var item = {}
item.item_name = '{{ cart.abonnementProCart.abonnement.name }}';
item.item_category = 'subscription';
item.price = {{ cart.abonnementProCart.prixTtc }};
item.quantity = 1;
items.push(item);
{% endif %}
{% endif %}
</script>
{% if app.request.attributes.get('_route') in ['checkout'] %}
<script>
dataLayer.push({ ecommerce: null });
items.forEach(myFunctionItem);
function myFunctionItem(item){
dataLayer.push({
event: 'begin_checkout',
delivery_adress: '{{ sessionLivraisontag.addresseAdresse }}',
user_type:'{{ user_type }}',
user_login_status:'{{ user_login_status }}',
ecommerce: {
items: [item]
}
});
}
</script>
{% endif %}
<script>
var itemsOrder = []
{% if order is defined %}
{% for detail in order.orderDetail %}
var item1 = {}
{% if detail.product.isColorLab %}
{% if detail.productAttribute.typeFormat.id is defined %}
item1.item_name = '{{ detail.product.titre~' '~detail.productAttribute.typeFormat.name }}';
{% else %}
item1.item_name = '{{ detail.product.titre }}';
{% endif %}
{% else %}
{% if detail.productAttribute.format.id is defined %}
item1.item_name = '{{ detail.product.titre~' '~detail.productAttribute.format.name }}';
{% else %}
item1.item_name = '{{ detail.product.titre }}';
{% endif %}
{% endif %}
item1.item_id = '{{ detail.id }}';
item1.item_category = 'articles';
item1.price = {{ order.prixTtc }};
item1.quantity = 1;
{% if order.isPromo and order.codePromo.name is defined %}
item1.coupon = '{{ order.codePromo.name }}';
{% endif %}
itemsOrder.push(item1);
{% endfor %}
{% endif %}
</script>
{% if app.request.attributes.get('_route') in ['checkout_verifie','checkout_poste_verifie'] %}
<script>
dataLayer.push({ ecommerce: null });
itemsOrder.forEach(myFunctionItemOrder);
function myFunctionItemOrder(item){
dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id: "T_"+item.item_id + "{{ '_'~ order.id }}",
value: {{ order.prixTtc}},
currency:"EUR",
items: [item]
}
});
}
{% if order is defined %}
{% if order.cart.abonnementProCart %}
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: 'purchase',
ecommerce: {
transaction_id:"T_"+{{ order.cart.abonnementProCart.id ~'_'~ order.id }},
value: {{ order.prixTtc}},
currency:"EUR",
items: [{
item_id : '{{ order.cart.abonnementProCart.id }}',
item_name : '{{ order.cart.abonnementProCart.abonnement.name }}',
item_category : 'subscription',
price : {{ order.prixTtc}},
quantity : 1
}]
}
});
{% endif %}
{% endif %}
</script>
{% endif %}
{% if app.request.attributes.get('_route') in ['accueil_page_b2b'] %}
{% if tagGoogle is defined and tagGoogle %}
<script>
dataLayer.push({
event: 'registration_success',
event_group: 'registration_btob',
page_title: 'formulaire inscrit abonnement',
page_category: 'subscription',
});
</script>
{% endif %}
{% endif %}