【发布时间】:2018-05-09 20:42:40
【问题描述】:
这是我在标题中与 Google Analytics 相关的代码:
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-ID"> </script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-ID');
</script>
这是底部包含在我的 JavaScript 文件中的代码:
// Send Google Analytics data if the cookie does not exist
if (document.cookie.indexOf("internalTest=") === -1) {
window.ga = window.ga || function () {
(ga.q = ga.q || []).push(arguments)
};
ga.l = +new Date;
ga('create', 'UA-ID', 'auto');
ga('send', 'pageview');
}
cookie homeTest 存在于我的笔记本电脑上,但它仍会在 Analytics 中实时显示数据。
我做错了什么?
谢谢。
【问题讨论】:
标签: javascript cookies google-analytics