实施Google Analytics(分析)是否正确?
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-000000- 00"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-000000-00');
gtag('config', 'UA-000000-00', { 'anonymize_ip': true, 'forceSSL': true, 'anonymize_ip': true });
gtag('config', 'UA-000000-00', {'page_title' : 'home', 'page_path': '/'});
答案 0 :(得分:1)
在阅读文档时,您似乎缺少了“事件”,并且已将值放置在配置中。
https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-000000- 00"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-000000-00');
gtag('config', 'UA-000000-00', {'metric1': 'anonymize_ip', 'metric2': 'forceSSL'});
gtag('config', 'UA-000000-00', {'metric3': 'page_title', 'metric4': 'page_path'});
gtag('event', 'send', {'anonymize_ip': true, 'forceSSL': true,'page_title': 'home', 'page_path': '/');
我删除了重复的anonymize_ip
之一。