简体   繁体   English

即使从网站成功触发,User_timing 谷歌分析数据也不会显示在分析仪表板上

[英]User_timing google analytics data not showing on analytics dashboard even if successfully fired from website

I am working with angular and using the navigation_start and end events in app.component.ts to measure the timiing and then firing a simple page_view and timing event.Both data are sended to analytics as seen in.network tab.Code is as follow:我正在使用 angular 并使用 app.component.ts 中的 navigation_start 和 end 事件来测量时间,然后触发一个简单的 page_view 和计时事件。两个数据都发送到分析,如在.network 选项卡中看到的那样。代码如下:

app.component.ts应用程序组件.ts

import { AuthService } from './core/services/auth.service';
import { Component, OnInit, Inject } from '@angular/core';
import { Router, NavigationEnd, NavigationStart } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { filter, map } from 'rxjs/operators';
import { BalakRoutes } from './core/constants/route.constant';
import { TimeTrackingService } from './shared/utils/time-tracking.service';

declare let gtag: Function;
@Component({
  // tslint:disable-next-line
  selector: 'body',
  template: '<router-outlet></router-outlet> <ngx-ui-loader></ngx-ui-loader>'
})
export class AppComponent implements OnInit {
  myAppUrl: string = '';
  private configLoadActionId: number;
  private navigationActionId: number;
  constructor(
    private router: Router,
    private authService: AuthService,
    private timingService: TimeTrackingService
  ) {
    this.myAppUrl = '/';
  }

  ngOnInit() {
    this.router.events.subscribe((evt) => {
      if (!(evt instanceof NavigationEnd)) {
        if (evt instanceof NavigationStart) {
          this.navigationActionId = this.timingService.startTracking(
            'navigation'
          );
        }

        return;
      } else {
        const result = this.timingService.stopTracking(this.navigationActionId);
        gtag('config', 'UA-176408533-1', {
          page_path: evt.urlAfterRedirects
        });
        gtag('event', 'timing_complete', {
          name: 'load',
          event_label: 'load : ' + evt.urlAfterRedirects,
          value: result.elapsed
        });
        window.scrollTo(0, 0);
      }
    });
  }
}


timingService works fine and returns proper values so I am not showing here. timingService 工作正常并返回正确的值,所以我没有在这里显示。

正在发送的数据的网络选项卡证明

分析证明

Note: There is no issue that I am not able to see bcoz of some sampling issue.I can't see even after 48 hrs注意:没有问题,我无法看到某些采样问题的 bcoz。即使在 48 小时后我也看不到

Try to use 'event_category' parameter instead 'name':尝试使用“event_category”参数代替“name”:

gtag('event', <action>, {
  'event_category': <category>,
  'event_label': <label>,
  'value': <value>
});

https://developers.google.com/analytics/devguides/collection/gtagjs/events https://developers.google.com/analytics/devguides/collection/gtagjs/events

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM