adjust view_item_list
add categories to ecommerce-DataLayer
This commit is contained in:
parent
e48b21022c
commit
bfc2ca8ad6
@ -1,5 +1,6 @@
|
|||||||
[{$smarty.block.parent}]
|
[{$smarty.block.parent}]
|
||||||
[{assign var="gtmProducts" value=$oView->getArticleList()}]
|
[{assign var="gtmProducts" value=$oView->getArticleList()}]
|
||||||
|
[{assign var="gtmCategory" value=$oView->getActiveCategory()}]
|
||||||
|
|
||||||
[{assign var="breadCrumb" value=''}]
|
[{assign var="breadCrumb" value=''}]
|
||||||
|
|
||||||
@ -8,12 +9,19 @@
|
|||||||
<script>
|
<script>
|
||||||
/* ga4 */
|
/* ga4 */
|
||||||
dataLayer.push({ecommerce: null});
|
dataLayer.push({ecommerce: null});
|
||||||
|
|
||||||
|
let itemCategories = '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]no category[{/if}]'.split('/');
|
||||||
|
|
||||||
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_category': itemCategories[0] || 'no category',
|
||||||
'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]',
|
'item_category_2':itemCategories[1] || '',
|
||||||
|
'item_category_3':itemCategories[2] || '',
|
||||||
|
'item_category_4':itemCategories[3] || '',
|
||||||
|
'item_list_id': '[{$oView->getCategoryId()}]',
|
||||||
|
'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()}]
|
||||||
|
Loading…
Reference in New Issue
Block a user