gpt4 book ai didi

javascript - 同步通用分析

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:49:28 25 4
gpt4 key购买 nike

新的 Universal Analytics 重新引入了同步事件跟踪:https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#sync .

但是文档不完整,它说:

"This calling syntax will not work when loading the analytics.js library using the default snippet. The default snippet is designed to work with the asynchronous calling syntax."

所以现在我只有一个默认(异步)片段:

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-YY', 'mydomain.com');
ga('send', 'pageview');

</script>

我找不到任何关于同步调用的正确片段的提及。有人吗?

最佳答案

使用这个:

<script src="//www.google-analytics.com/analytics.js"></script>
<script>
var tracker = ga.create('UA-12345678-1', 'auto');
tracker.send('pageview');
</script>

已测试。

关于javascript - 同步通用分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18146182/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com