在app.component.html文件中,我只有两个标签。<nav-bar>和<router-outlet>标签。要添加Google跟踪代码管理器代码段,我们都知道,<script>应将标记插入<head>html文件的<noscript>标记内,并将标记插入<body>标记内。由于我没有<head>和<body>在app.component.html文件标记,它们自动生成的,我应该在哪里插入此谷歌标签管理器标签片段?
2 回答

忽然笑
TA贡献1806条经验 获得超5个赞
我不确定Google标记管理器,但可以在app.component模板中进行设置,也可以将它放在index.html的底部,例如
<script>
dataLayer = [{
'pageCategory': 'signup',
'visitorType': 'high-value'
}];
</script>
<!-- Google Tag Manager -->
...
<!-- End Google Tag Manager -->

吃鸡游戏
TA贡献1829条经验 获得超7个赞
请记住,最好将dataLayer保留为空数组,并在组件级别设置属性。否则,如果您忘记显式设置这些值,它们将保留其原始值。像这样在标记管理器脚本之前进行简单的初始化即可使您启动并运行。
window.dataLayer = window.dataLayer || [];
添加回答
举报
0/150
提交
取消