如何结合使用Google Analytics(分析)和Google AdWords gtag.js?

时间:2018-07-23 19:39:03

标签: google-analytics google-adwords

我的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>

在哪里以及如何一起找到这些代码?

1 个答案:

答案 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>中。

https://support.google.com/google-ads/answer/7548399?hl=en