[rework] change structure of GA-event
moving the procedere into one step so there's not an accidental triggering of an GA-Push-Event which at the end overwrites the View-Item-Push-Event in the cmpEvent
This commit is contained in:
parent
d4ef0f35f9
commit
5ed924e840
@ -1,56 +1,47 @@
|
|||||||
[{$smarty.block.parent}]
|
[{$smarty.block.parent}]
|
||||||
|
|
||||||
[{assign var="d3ProductObject" value=$oView->getProduct()}]
|
[{* variable $gtmProduct is passed from parent tempalte *}]
|
||||||
[{assign var="d3PriceObject" value=$d3ProductObject->getPrice()}]
|
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
|
||||||
|
[{assign var="gtmCurrency" value=$oView->getActCurrency()}]
|
||||||
|
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
|
||||||
|
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
|
||||||
|
|
||||||
[{capture assign=d3_ga4_add_to_cart}]
|
[{capture assign=d3_ga4_add_to_cart}]
|
||||||
[{block name="d3_ga4_add_to_basket"}]
|
[{block name="d3_ga4_add_to_basket"}]
|
||||||
$("#toBasket").click(function(event) {
|
$("#toBasket").click(function(event) {
|
||||||
|
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
||||||
|
|
||||||
[{*** Debug cases ***}]
|
let itemCategories = '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]no category[{/if}]'.split('/');
|
||||||
[{*event.preventDefault();*}]
|
|
||||||
|
|
||||||
let iArtQuantity = $("#amountToBasket").val();
|
[{*** Debug cases ***}]
|
||||||
|
[{*event.preventDefault();*}]
|
||||||
|
|
||||||
dataLayer.push({
|
let iArtQuantity = $("#amountToBasket").val();
|
||||||
'isAddToBasket': true,
|
|
||||||
'event':'add_to_cart',
|
dataLayer.push({
|
||||||
'eventLabel': 'add_to_cart',
|
'isAddToBasket': true,
|
||||||
'ecommerce': {
|
'event':'add_to_cart',
|
||||||
'currency': "[{$currency->name}]",
|
'eventLabel': 'add_to_cart',
|
||||||
'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
|
'ecommerce': {
|
||||||
'items': [
|
'currency': "[{$currency->name}]",
|
||||||
{
|
'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
|
||||||
'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]',
|
'items': [
|
||||||
'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]',
|
{
|
||||||
'price': [{$d3PriceObject->getPrice()}],
|
'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]',
|
||||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]',
|
||||||
'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
'price': [{$d3PriceObject->getPrice()}],
|
||||||
'item_category': itemCategories[0] || 'no category',
|
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||||
'item_category_2':itemCategories[1] || '',
|
'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
||||||
'item_category_3':itemCategories[2] || '',
|
'item_category': itemCategories[0] || 'no category',
|
||||||
'item_category_4':itemCategories[3] || '',
|
'item_category_2':itemCategories[1] || '',
|
||||||
'quantity': iArtQuantity
|
'item_category_3':itemCategories[2] || '',
|
||||||
}
|
'item_category_4':itemCategories[3] || '',
|
||||||
]
|
'quantity': iArtQuantity
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
[{/block}]
|
[{/block}]
|
||||||
[{/capture}]
|
[{/capture}]
|
||||||
[{oxscript add=$d3_ga4_add_to_cart}]
|
[{oxscript add=$d3_ga4_add_to_cart}]
|
||||||
|
|
||||||
[{strip}]
|
|
||||||
[{* variable $gtmProduct is passed from parent tempalte *}]
|
|
||||||
|
|
||||||
[{assign var="gtmCurrency" value=$oView->getActCurrency()}]
|
|
||||||
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
|
|
||||||
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
|
|
||||||
|
|
||||||
<script>
|
|
||||||
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
|
||||||
|
|
||||||
let itemCategories = '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]no category[{/if}]'.split('/');
|
|
||||||
|
|
||||||
</script>
|
|
||||||
[{/strip}]
|
|
Loading…
Reference in New Issue
Block a user