Google Analytics(分析)自定义指标不适用于Angle 6

时间:2018-10-17 07:53:00

标签: angular google-analytics angular6 angular-components

我已经在Google Analytics(分析)上创建了一个自定义指标,并在模板中提到了所需的变量:

import {Injectable} from "@angular/core";
declare let ga: Function;
@Injectable()
export class GoogleAnalyticsEventsService {

  public emitEvent(eventCategory: string,
                   eventAction: string,
                   eventLabel: string = null,
                   eventValue: number = null) {
    ga('send', 'event', {
      eventCategory: eventCategory,
      eventLabel: eventLabel,
      eventAction: eventAction,
      eventValue: eventValue
    });
  }

}

在我的组件中,我已经这样提到过:

var metricValue = '1';
ga('set', 'metric6', metricValue);

但是以某种方式,它不起作用。请帮助

0 个答案:

没有答案