【发布时间】:2019-07-06 20:53:45
【问题描述】:
我想使用谷歌分析跟踪页面加载时间。我有一个单页应用程序。为了跟踪,我在 head 标签内添加了给定的脚本。为了获得页面加载时间,我在正文标记之前添加了第二个脚本,但不幸的是我无法在 Google Analytics 中找到与此相对应的任何事件。似乎这个 gtag() 没有以某种方式执行。有人可以帮忙吗。此外,我们在 Google 分析中哪里可以看到 event_value。我可以通过进入 RealTime->Events 找到 event_category 和 event_action,但我在那里找不到任何 event_value。
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
</script>
<script>
if(window.performance){
// Gets the number of milliseconds since page load
// (and rounds the result since the value must be an integer).
var timeSincePageLoad = Math.round(performance.now());
// Sends the timing event to Google Analytics.
gtag('event', 'timing_complete', {
'name': 'load',
'event_value': timeSincePageLoad,
'event_category': 'Home page loading time'
});
}
</script>
【问题讨论】:
标签: google-analytics google-analytics-api google-analytics-filters google-analytics-firebase