2023-01-11 14:43:13 +01:00
|
|
|
[{$smarty.block.parent}]
|
|
|
|
|
2023-06-19 11:34:45 +02:00
|
|
|
[{* variable $gtmProduct is passed from parent tempalte *}]
|
|
|
|
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
|
|
|
|
[{assign var="gtmCurrency" value=$oView->getActCurrency()}]
|
|
|
|
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
|
|
|
|
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
|
2023-01-11 14:43:13 +01:00
|
|
|
|
2023-08-17 08:50:15 +02:00
|
|
|
[{block name="d3_ga4_add_to_cart_block"}]
|
|
|
|
[{capture assign=d3_ga4_add_to_cart}]
|
|
|
|
[{strip}]
|
|
|
|
$("#toBasket").click(function(event) {
|
|
|
|
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
2023-06-19 11:34:45 +02:00
|
|
|
|
2023-08-17 08:50:15 +02:00
|
|
|
[{*** Debug cases ***}]
|
|
|
|
[{*event.preventDefault();*}]
|
2023-06-19 11:34:45 +02:00
|
|
|
|
2023-08-17 08:50:15 +02:00
|
|
|
let iArtQuantity = $("#amountToBasket").val();
|
2023-06-19 11:34:45 +02:00
|
|
|
|
2023-08-17 08:50:15 +02:00
|
|
|
dataLayer.push({
|
|
|
|
'isAddToBasket': true,
|
|
|
|
'event':'add_to_cart',
|
|
|
|
'eventLabel': 'add_to_cart',
|
|
|
|
'ecommerce': {
|
|
|
|
'currency': "[{$currency->name}]",
|
|
|
|
'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
|
|
|
|
'items': [
|
|
|
|
{
|
|
|
|
'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]',
|
|
|
|
'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]',
|
|
|
|
'price': [{$d3PriceObject->getPrice()}],
|
|
|
|
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
|
|
|
'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
|
|
|
[{if $gtmCategory}]
|
|
|
|
'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]',
|
|
|
|
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]',
|
|
|
|
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]',
|
|
|
|
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]',
|
|
|
|
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
|
|
|
|
[{/if}]
|
|
|
|
'quantity': iArtQuantity
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}[{if $oViewConf->isDebugModeOn()}],
|
|
|
|
'debug_mode': 'true'
|
|
|
|
[{/if}]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
[{/strip}]
|
2023-06-19 11:34:45 +02:00
|
|
|
[{/capture}]
|
2023-08-17 08:50:15 +02:00
|
|
|
[{oxscript add=$d3_ga4_add_to_cart}]
|
|
|
|
[{/block}]
|