genuine reworking structure and aligning all

This commit is contained in:
MaxBUhe 2023-01-11 15:25:02 +01:00
parent c83e908da1
commit 664119f89e
2 changed files with 32 additions and 36 deletions

View File

@ -8,30 +8,28 @@
'event': 'purchase',
'eventLabel':'Checkout Step 5',
'ecommerce': {
'purchase': {
'actionField': {
'id':'[{$_gtmOrder->oxorder__oxordernr->value}]',
'affiliation':'[{$oxcmp_shop->oxshops__oxname->value}]',
'revenue':'[{$_gtmOrder->oxorder__oxtotalordersum->value}]',
'tax':'[{math equation="x+y" x=$_gtmOrder->oxorder__oxartvatprice1->value y=$_gtmOrder->oxorder__oxartvatprice2->value }]',
'shipping':'[{$_gtmOrder->oxorder__oxdelcost->value}]',
'currency': "[{$_gtmOrder->getFieldData('oxcurrency')}]"
},
'products':[
[{foreach from=$_gtmArticles item="_gtmArticle" name="gtmArticles"}]
{
'id':'[{$_gtmArticle->oxorderarticles__oxartnum->value}]',
'name': '[{$_gtmArticle->oxorderarticles__oxtitle->value}]',
'variant':'[{$_gtmArticle->oxorderarticles__oxselvariant->value}]',
'price': [{$_gtmArticle->oxorderarticles__oxprice->value}],
'quantity':[{$_gtmArticle->oxorderarticles__oxamount->value}],
'position':[{$smarty.foreach.gtmArticles.iteration}]
}[{if !$smarty.foreach.gtmArticles.last}],[{/if}]
[{/foreach}]
]
'transaction_id':'[{$_gtmOrder->oxorder__oxordernr->value}]',
'affiliation':'[{$oxcmp_shop->oxshops__oxname->value}]',
'value':'[{$_gtmOrder->oxorder__oxtotalordersum->value}]',
'tax':'[{math equation="x+y" x=$_gtmOrder->oxorder__oxartvatprice1->value y=$_gtmOrder->oxorder__oxartvatprice2->value }]',
'shipping':'[{$_gtmOrder->oxorder__oxdelcost->value}]',
'currency': "[{$_gtmOrder->getFieldData('oxcurrency')}]"
'items':
[
[{foreach from=$_gtmArticles item="_gtmArticle" name="gtmArticles"}]
{
'id':'[{$_gtmArticle->oxorderarticles__oxartnum->value}]',
'name': '[{$_gtmArticle->oxorderarticles__oxtitle->value}]',
'variant':'[{$_gtmArticle->oxorderarticles__oxselvariant->value}]',
'price': [{$_gtmArticle->oxorderarticles__oxprice->value}],
'quantity':[{$_gtmArticle->oxorderarticles__oxamount->value}],
'position':[{$smarty.foreach.gtmArticles.iteration}]
}[{if !$smarty.foreach.gtmArticles.last}],[{/if}]
[{/foreach}]
]
}
}
});
})
</script>
[{/strip}]
[{$smarty.block.parent}]

View File

@ -2,26 +2,24 @@
[{assign var="gtmProduct" value=$oView->getProduct()}]
[{assign var="gtmCategory" value=$gtmProduct->getCategory()}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
[{strip}][{/strip}]
<script>
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
dataLayer.push({
'event': 'view_item',
'eventLabel':'Product View',
'ecommerce': {
'currencyCode': '[{$currency->name}]',
'detail': {
'products': [
{
'name': '[{$gtmProduct->oxarticles__oxtitle->value}]',
'id': '[{$gtmProduct->oxarticles__oxartnum->value}]',
'price': [{$gtmProduct->oxarticles__oxprice->value}],
'brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
'variant': '[{if $gtmProduct->oxarticles__oxvarselect->value}][{$gtmProduct->oxarticles__oxvarselect->value}][{/if}]'
}
]
}
'currency': '[{$currency->name}]',
'items': [
{
'item_name': '[{$gtmProduct->oxarticles__oxtitle->value}]',
'item_id': '[{$gtmProduct->oxarticles__oxartnum->value}]',
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
'item_variant': '[{if $gtmProduct->oxarticles__oxvarselect->value}][{$gtmProduct->oxarticles__oxvarselect->value}][{/if}]',
'price': [{$gtmProduct->oxarticles__oxprice->value}]
}
]
}
});
</script>