[working-state] rebuilding meta structure

This commit is contained in:
MaxBUhe 2023-08-03 15:55:07 +02:00
parent 71b743ddcc
commit 0f15df8364
7 changed files with 246 additions and 226 deletions

View File

@ -1,51 +1,54 @@
[{$smarty.block.parent}] [{$smarty.block.parent}]
[{strip}] [{block name="d3_ga4_purchase_block"}]
<script> [{capture assign=d3_ga4_purchase}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ [{strip}]
[{assign var="gtmOrder" value=$oView->getOrder()}] dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
[{assign var="gtmBasket" value=$oView->getBasket()}] [{assign var="gtmOrder" value=$oView->getOrder()}]
[{assign var="gtmArticles" value=$gtmOrder->getOrderArticles()}] [{assign var="gtmBasket" value=$oView->getBasket()}]
[{assign var="gtmOrderVouchers" value=$gtmOrder->getVoucherNrList()}] [{assign var="gtmArticles" value=$gtmOrder->getOrderArticles()}]
[{assign var="gtmOrderVouchers" value=$gtmOrder->getVoucherNrList()}]
dataLayer.push({ dataLayer.push({
'event': 'purchase', 'event': 'purchase',
'eventLabel':'Checkout Step 5', 'eventLabel':'Checkout Step 5',
'ecommerce': { 'ecommerce': {
'transaction_id': '[{$gtmOrder->getFieldData("oxordernr")}]', 'transaction_id': '[{$gtmOrder->getFieldData("oxordernr")}]',
'affiliation': '[{$oxcmp_shop->getFieldData("oxname")}]', 'affiliation': '[{$oxcmp_shop->getFieldData("oxname")}]',
'value': [{$gtmOrder->getTotalOrderSum()}], 'value': [{$gtmOrder->getTotalOrderSum()}],
'tax': [{math equation="x+y" x=$gtmOrder->getFieldData("oxartvatprice1") y=$gtmOrder->getFieldData("oxartvatprice2") }], 'tax': [{math equation="x+y" x=$gtmOrder->getFieldData("oxartvatprice1") y=$gtmOrder->getFieldData("oxartvatprice2") }],
'shipping': [{$gtmOrder->getFieldData("oxdelcost")}], 'shipping': [{$gtmOrder->getFieldData("oxdelcost")}],
'currency': '[{$gtmOrder->getFieldData('oxcurrency')}]', 'currency': '[{$gtmOrder->getFieldData('oxcurrency')}]',
'coupon': '[{foreach from=$gtmOrderVouchers item="gtmOrderVoucher" name="gtmOrderVoucherIteration"}][{$gtmOrderVoucher}][{if !$smarty.foreach.gtmOrderVoucherIteration.last}], [{/if}][{/foreach}]', 'coupon': '[{foreach from=$gtmOrderVouchers item="gtmOrderVoucher" name="gtmOrderVoucherIteration"}][{$gtmOrderVoucher}][{if !$smarty.foreach.gtmOrderVoucherIteration.last}], [{/if}][{/foreach}]',
'paymentType': '[{$gtmBasket->getPaymentOnPaymentId()}]', 'paymentType': '[{$gtmBasket->getPaymentOnPaymentId()}]',
'items': [ 'items': [
[{foreach from=$gtmArticles item="gtmBasketItem" name="gtmArticles"}] [{foreach from=$gtmArticles item="gtmBasketItem" name="gtmArticles"}]
[{assign var="gtmPurchaseItemPriceObject" value=$gtmBasketItem->getPrice()}] [{assign var="gtmPurchaseItemPriceObject" value=$gtmBasketItem->getPrice()}]
[{assign var="gtmPurchaseItem" value=$gtmBasketItem->getArticle()}] [{assign var="gtmPurchaseItem" value=$gtmBasketItem->getArticle()}]
[{assign var="gtmPurchaseItemCategory" value=$gtmPurchaseItem->getCategory()}] [{assign var="gtmPurchaseItemCategory" value=$gtmPurchaseItem->getCategory()}]
{ {
'item_id': '[{$gtmBasketItem->getFieldData("oxartnum")}]', 'item_id': '[{$gtmBasketItem->getFieldData("oxartnum")}]',
'item_name': '[{$gtmBasketItem->getFieldData("oxtitle")}]', 'item_name': '[{$gtmBasketItem->getFieldData("oxtitle")}]',
'affiliation': '[{$gtmBasketItem->getFieldData("oxtitle")}]', 'affiliation': '[{$gtmBasketItem->getFieldData("oxtitle")}]',
'coupon': '[{foreach from=$gtmOrderVouchers item="gtmOrderVoucher" name="gtmOrderVoucherIteration"}][{$gtmOrderVoucher}][{if !$smarty.foreach.gtmOrderVoucherIteration.last}], [{/if}][{/foreach}]', 'coupon': '[{foreach from=$gtmOrderVouchers item="gtmOrderVoucher" name="gtmOrderVoucherIteration"}][{$gtmOrderVoucher}][{if !$smarty.foreach.gtmOrderVoucherIteration.last}], [{/if}][{/foreach}]',
'item_variant': '[{$gtmBasketItem->getFieldData("oxselvariant")}]', 'item_variant': '[{$gtmBasketItem->getFieldData("oxselvariant")}]',
[{if $gtmPurchaseItemCategory}] [{if $gtmPurchaseItemCategory}]
'item_category': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(0)}]', 'item_category': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(0)}]',
'item_category_2': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(1)}]', 'item_category_2': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(1)}]',
'item_category_3': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(2)}]', 'item_category_3': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(2)}]',
'item_category_4': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(3)}]', 'item_category_4': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(3)}]',
'item_list_name': '[{$gtmPurchaseItemCategory->getSplitCategoryArray()}]', 'item_list_name': '[{$gtmPurchaseItemCategory->getSplitCategoryArray()}]',
[{/if}] [{/if}]
'price': [{$gtmPurchaseItemPriceObject->getPrice()}], 'price': [{$gtmPurchaseItemPriceObject->getPrice()}],
'quantity': [{$gtmBasketItem->getFieldData("oxamount")}], 'quantity': [{$gtmBasketItem->getFieldData("oxamount")}],
'position': [{$smarty.foreach.gtmArticles.iteration}] 'position': [{$smarty.foreach.gtmArticles.iteration}]
}[{if !$smarty.foreach.gtmArticles.last}],[{/if}] }[{if !$smarty.foreach.gtmArticles.last}],[{/if}]
[{/foreach}] [{/foreach}]
] ]
} }
}) })
</script> [{/strip}]
[{/strip}] [{/capture}]
[{oxscript add=$d3_ga4_purchase}]
[{/block}]

View File

@ -5,40 +5,44 @@
[{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}] [{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}]
[{assign var='gtmCartArticles' value=$oView->getBasketArticles()}] [{assign var='gtmCartArticles' value=$oView->getBasketArticles()}]
[{strip}][{capture assign=d3_ga4_view_cart}] [{block name="d3_ga4_view_cart_block"}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ [{capture assign=d3_ga4_view_cart}]
dataLayer.push({ [{strip}]
'event': 'view_cart', dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
'eventLabel':'Checkout Step 1', dataLayer.push({
'ecommerce': { 'event': 'view_cart',
'actionField': "step: 1", 'eventLabel':'Checkout Step 1',
'currency': "[{$currency->name}]", 'ecommerce': {
'value': [{$d3BasketPrice->getPrice()}], 'actionField': "step: 1",
'coupon': '[{foreach from=$oxcmp_basket->getVouchers() item=sVoucher key=key name=Voucher}][{$sVoucher->sVoucherNr}][{if !$smarty.foreach.Voucher.last}], [{/if}][{/foreach}]', 'currency': "[{$currency->name}]",
'items': [ 'value': [{$d3BasketPrice->getPrice()}],
[{foreach from=$oxcmp_basket->getContents() item=basketitem name=gtmCartContents key=basketindex}] 'coupon': '[{foreach from=$oxcmp_basket->getVouchers() item=sVoucher key=key name=Voucher}][{$sVoucher->sVoucherNr}][{if !$smarty.foreach.Voucher.last}], [{/if}][{/foreach}]',
[{assign var="d3oItemPrice" value=$basketitem->getPrice()}] 'items': [
[{assign var="gtmBasketItem" value=$basketitem->getArticle()}] [{foreach from=$oxcmp_basket->getContents() item=basketitem name=gtmCartContents key=basketindex}]
[{assign var="gtmBasketItemCategory" value=$gtmBasketItem->getCategory()}] [{assign var="d3oItemPrice" value=$basketitem->getPrice()}]
{ [{assign var="gtmBasketItem" value=$basketitem->getArticle()}]
'item_id': '[{$gtmCartArticles[$basketindex]->getFieldData('oxartnum')}]', [{assign var="gtmBasketItemCategory" value=$gtmBasketItem->getCategory()}]
'item_name': '[{$gtmCartArticles[$basketindex]->getFieldData('oxtitle')}]', {
'item_variant': '[{$gtmCartArticles[$basketindex]->getFieldData('oxvarselect')}]', 'item_id': '[{$gtmCartArticles[$basketindex]->getFieldData('oxartnum')}]',
[{if $gtmBasketItemCategory}] 'item_name': '[{$gtmCartArticles[$basketindex]->getFieldData('oxtitle')}]',
'item_category': '[{$gtmBasketItemCategory->getSplitCategoryArray(0)}]', 'item_variant': '[{$gtmCartArticles[$basketindex]->getFieldData('oxvarselect')}]',
'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1)}]', [{if $gtmBasketItemCategory}]
'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2)}]', 'item_category': '[{$gtmBasketItemCategory->getSplitCategoryArray(0)}]',
'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3)}]', 'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1)}]',
'item_list_name': '[{$gtmBasketItemCategory->getSplitCategoryArray()}]', 'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2)}]',
[{/if}] 'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3)}]',
'price': [{$d3oItemPrice->getPrice()}], 'item_list_name': '[{$gtmBasketItemCategory->getSplitCategoryArray()}]',
'coupon': '[{foreach from=$oxcmp_basket->getVouchers() item=sVoucher key=key name=Voucher}][{$sVoucher->sVoucherNr}][{if !$smarty.foreach.Voucher.last}], [{/if}][{/foreach}]', [{/if}]
'quantity': [{$basketitem->getAmount()}], 'price': [{$d3oItemPrice->getPrice()}],
'position': [{$smarty.foreach.gtmCartContents.index}] 'coupon': '[{foreach from=$oxcmp_basket->getVouchers() item=sVoucher key=key name=Voucher}][{$sVoucher->sVoucherNr}][{if !$smarty.foreach.Voucher.last}], [{/if}][{/foreach}]',
}[{if !$smarty.foreach.gtmCartContents.last}],[{/if}] 'quantity': [{$basketitem->getAmount()}],
[{/foreach}] 'position': [{$smarty.foreach.gtmCartContents.index}]
] }[{if !$smarty.foreach.gtmCartContents.last}],[{/if}]
} [{/foreach}]
}); ]
[{/capture}][{/strip}] }
[{oxscript add=$d3_ga4_view_cart}] });
[{/strip}]
[{/capture}]
[{oxscript add=$d3_ga4_view_cart}]
[{/block}]

View File

@ -3,31 +3,36 @@
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}] [{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
<script> [{block name="d3_ga4_view_item_block"}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ [{capture assign=d3_ga4_view_item}]
[{strip}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
dataLayer.push({ dataLayer.push({
'event': 'view_item', 'event': 'view_item',
'eventLabel':'Product View', 'eventLabel':'Product View',
'ecommerce': { 'ecommerce': {
'currency': '[{$currency->name}]', 'currency': '[{$currency->name}]',
'items': [ 'items': [
{ {
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]', 'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]', 'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_variant': '[{if $gtmProduct->getFieldData("oxvarselect")}][{$gtmProduct->getFieldData("oxvarselect")}][{/if}]', 'item_variant': '[{if $gtmProduct->getFieldData("oxvarselect")}][{$gtmProduct->getFieldData("oxvarselect")}][{/if}]',
[{if $gtmCategory}] [{if $gtmCategory}]
'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]', 'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]',
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]', 'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]',
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]', 'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]',
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]', 'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]',
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]', 'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
[{/if}] [{/if}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}] [{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
'price': [{$d3PriceObject->getPrice()}] 'price': [{$d3PriceObject->getPrice()}]
}
]
} }
] });
} [{/strip}]
}); [{/capture}]
</script> [{oxscript add=$d3_ga4_view_item}]
[{/block}]

View File

@ -6,43 +6,45 @@
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}] [{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
[{capture assign=d3_ga4_add_to_cart}] [{block name="d3_ga4_add_to_cart_block"}]
[{block name="d3_ga4_add_to_basket"}] [{capture assign=d3_ga4_add_to_cart}]
$("#toBasket").click(function(event) { [{strip}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ $("#toBasket").click(function(event) {
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
[{*** Debug cases ***}] [{*** Debug cases ***}]
[{*event.preventDefault();*}] [{*event.preventDefault();*}]
let iArtQuantity = $("#amountToBasket").val(); let iArtQuantity = $("#amountToBasket").val();
dataLayer.push({ dataLayer.push({
'isAddToBasket': true, 'isAddToBasket': true,
'event':'add_to_cart', 'event':'add_to_cart',
'eventLabel': 'add_to_cart', 'eventLabel': 'add_to_cart',
'ecommerce': { 'ecommerce': {
'currency': "[{$currency->name}]", 'currency': "[{$currency->name}]",
'value': iArtQuantity*[{$d3PriceObject->getPrice()}], 'value': iArtQuantity*[{$d3PriceObject->getPrice()}],
'items': [ 'items': [
{ {
'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]', 'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]',
'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]', 'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]',
'price': [{$d3PriceObject->getPrice()}], 'price': [{$d3PriceObject->getPrice()}],
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]', 'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]',
[{if $gtmCategory}] [{if $gtmCategory}]
'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]', 'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]',
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]', 'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]',
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]', 'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]',
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]', 'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]',
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]', 'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
[{/if}] [{/if}]
'quantity': iArtQuantity 'quantity': iArtQuantity
} }
] ]
} }
}); });
}); });
[{/block}] [{/strip}]
[{/capture}] [{/capture}]
[{oxscript add=$d3_ga4_add_to_cart}] [{oxscript add=$d3_ga4_add_to_cart}]
[{/block}]

View File

@ -1,10 +1,10 @@
[{$smarty.block.parent}] [{$smarty.block.parent}]
[{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}] [{block name="d3_ga4_remove_from_cart_block"}]
[{if $hasBeenReloaded}]
[{if $hasBeenReloaded}] [{assign var="d3BasketPrice" value=$oxcmp_basket->getPrice()}]
[{strip}] [{capture assign=d3_ga4_remove_from_cart}]
[{capture assign=d3_ga4_view_cart}] [{strip}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
dataLayer.push({ dataLayer.push({
'isRemoveFromCart': true, 'isRemoveFromCart': true,
@ -39,7 +39,8 @@
] ]
} }
}); });
[{/capture}] [{/strip}]
[{/strip}] [{/capture}]
[{oxscript add=$d3_ga4_view_cart}] [{oxscript add=$d3_ga4_remove_from_cart}]
[{/if}] [{/if}]
[{/block}]

View File

@ -4,39 +4,41 @@
[{assign var="breadCrumb" value=''}] [{assign var="breadCrumb" value=''}]
[{if $gtmProducts|@count}] [{block name="d3_ga4_view_item_list_block"}]
[{strip}] [{if $gtmProducts|@count}]
<script> [{capture assign=d3_ga4_view_item_list}]
/* ga4 */ [{strip}]
dataLayer.push({ecommerce: null}); dataLayer.push({ecommerce: null});
dataLayer.push({ dataLayer.push({
'event':'view_item_list', 'event':'view_item_list',
'event_name': 'view_item_list', 'event_name': 'view_item_list',
'ecommerce': { 'ecommerce': {
'item_list_id': '[{$oView->getCategoryId()}]', 'item_list_id': '[{$oView->getCategoryId()}]',
'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]', 'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]',
'items': [ 'items': [
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}] [{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}] [{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}] [{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}]
{ {
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]', 'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]', 'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'price': [{$d3PriceObject->getPrice()}], 'price': [{$d3PriceObject->getPrice()}],
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
[{if $gtmCategory}] [{if $gtmCategory}]
'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]', 'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]',
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]', 'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]',
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]', 'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]',
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]', 'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]',
[{/if}] [{/if}]
'quantity': 1 'quantity': 1
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}] }[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
[{/foreach}] [{/foreach}]
] ]
} }
}); });
</script> [{/strip}]
[{/strip}] [{/capture}]
[{/if}] [{oxscript add=$d3_ga4_view_item_list}]
[{/if}]
[{/block}]

View File

@ -2,38 +2,41 @@
[{assign var="gtmProducts" value=$oView->getArticleList()}] [{assign var="gtmProducts" value=$oView->getArticleList()}]
[{if $gtmProducts|@count}] [{block name="d3_ga4_add_to_cart_block"}]
[{strip}] [{if $gtmProducts|@count}]
<script> [{capture assign=d3_ga4_add_to_cart}]
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ [{strip}]
dataLayer.push({ dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
'event': 'view_search_result', dataLayer.push({
'eventLabel':'view_search_result', 'event': 'view_search_result',
'ecommerce': { 'eventLabel':'view_search_result',
'search_term': '[{$searchparamforhtml}]', 'ecommerce': {
'items': [ 'search_term': '[{$searchparamforhtml}]',
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}] 'items': [
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}] [{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] [{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
{ [{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]', {
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]', 'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'price': [{$d3PriceObject->getPrice()}], 'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', 'price': [{$d3PriceObject->getPrice()}],
[{if $gtmCategory}] 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]', [{if $gtmCategory}]
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]', 'item_category': '[{$gtmCategory->getSplitCategoryArray(0)}]',
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]', 'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1)}]',
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]', 'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2)}]',
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]', 'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3)}]',
[{/if}] 'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
'quantity': 1 [{/if}]
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}] 'quantity': 1
[{/foreach}] }[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
] [{/foreach}]
} ]
}); }
</script> });
[{/strip}] [{/strip}]
[{/if}] [{/capture}]
[{oxscript add=$d3_ga4_add_to_cart}]
[{/if}]
[{/block}]