我的Google Analytics(分析)代码为:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-119899800-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-119899800-1');
</script>
Google AdWords为我提供了相同的代码,例如:
<!-- Global site tag (gtag.js) - Google AdWords: 796207283 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-796207283"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-796207283');
</script>
在哪里以及如何一起找到这些代码?
答案 0 :(得分:6)
您应该以这种方式合并代码:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-119899800-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-119899800-1');
gtag('config', 'AW-796207283');
</script>
并将其插入所需页面的<head>
中。