2023-01-11 14:43:13 +01:00
|
|
|
[{$smarty.block.parent}]
|
|
|
|
|
2023-05-10 15:01:56 +02:00
|
|
|
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
|
2023-01-11 14:43:13 +01:00
|
|
|
|
|
|
|
[{capture assign=d3_ga4_add_to_cart}]
|
2023-01-25 14:32:22 +01:00
|
|
|
[{block name="d3_ga4_add_to_basket"}]
|
2023-01-11 14:43:13 +01:00
|
|
|
$("#toBasket").click(function(event) {
|
|
|
|
[{*event.preventDefault();*}]
|
|
|
|
|
|
|
|
let iArtQuantity = $("#amountToBasket").val();
|
|
|
|
|
|
|
|
dataLayer.push({
|
|
|
|
'isAddToBasket': true,
|
|
|
|
'event':'add_to_cart',
|
|
|
|
'eventLabel': 'add_to_cart',
|
|
|
|
'ecommerce': {
|
|
|
|
'currency': "[{$currency->name}]",
|
2023-05-10 15:01:56 +02:00
|
|
|
'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
|
2023-01-11 14:43:13 +01:00
|
|
|
'items': [
|
|
|
|
{
|
|
|
|
'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]',
|
|
|
|
'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]',
|
2023-05-12 14:06:21 +02:00
|
|
|
'price': [{$d3PriceObject->getPrice()}],
|
2023-01-11 14:43:13 +01:00
|
|
|
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
|
|
|
'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
|
|
|
'item_category': itemCategories[0] || 'no category',
|
|
|
|
'item_category_2':itemCategories[1] || '',
|
|
|
|
'item_category_3':itemCategories[2] || '',
|
|
|
|
'item_category_4':itemCategories[3] || '',
|
|
|
|
'quantity': iArtQuantity
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2023-01-25 14:32:22 +01:00
|
|
|
[{/block}]
|
2023-01-11 14:43:13 +01:00
|
|
|
[{/capture}]
|
|
|
|
[{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('/');
|
2021-07-17 23:22:23 +02:00
|
|
|
|
|
|
|
</script>
|
|
|
|
[{/strip}]
|