我正在尝试使用Google跟踪代码管理器设置电子商务跟踪但是我无法将数据显示在Google Analytics中?在header.tpl中使用此类代码
{if isset($page_name) && $page_name|escape:'html':'UTF-8' == "order-confirmation"}
<script type="text/javascript">
window.dataLayer = window.dataLayer || []
dataLayer.push({ldelim}
'transactionId': '{$id_order}',
'transactionTotal': {$total_paid_tax_incl},
'transactionProducts': [
{foreach from=$products item=product}
{ldelim}
// List of productFieldObjects.
'sku': '{$product.id}',
'name': '{$product.name}', // Name or ID is required.
//'category': '{$product.X}',
'price': {$product.price},
'quantity': 1 // Optional fields may be omitted or set to empty string.
{rdelim}
{if !$smarty.foreach.product.last},{/if}
{/foreach}
]
{rdelim});
</script>
{/如果}
但没有任何作用
您的数据层声明需要高于GTM代码段。
GTM的noscript部分也应该紧接着。
我认为你应该查看文档,因为你有其他实现问题:
如何安装GTM:https://support.google.com/tagmanager/answer/6103696?hl=en&ref_topic=3441530
GTM的电子商务:https://support.google.com/tagmanager/answer/6107169?hl=en