【问题标题】:To get event corresponding to page load time in Google Analytics在 Google Analytics 中获取与页面加载时间对应的事件
【发布时间】: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


    【解决方案1】:

    根据documentation 应该是value,而不是event_value

      gtag('event', 'timing_complete', {
        'name': 'load',
        'value': timeSincePageLoad,
        'event_category': 'Home page loading time'
      });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-15
      • 2016-06-16
      • 1970-01-01
      • 2011-07-08
      • 1970-01-01
      • 2020-05-02
      • 2015-09-21
      • 2016-07-23
      相关资源
      最近更新 更多