google-analyticsangularangulartics

angulartics2 event does not work


I am using angulartics2.

import { Component } from '@angular/core';
import { Angulartics2On } from 'angulartics2';

@Component({
  selector: 'random-component',
  directives: [Angulartics2On],
  template: `
    <button angulartics2On angularticsEvent="Play" angularticsCategory="Videos" (click)="onClick()">Play</button>
  `
})
export class RandomComponent {
  onClick() {
    console.log('Hi');
  }
}

does not work for me. The effect does not show in the Google Analytics Debugger and Google Analytics Real-Time reports.

What may cause this? Thanks


Solution

  • I got answer from @JonnyBGod on github, and thanks!

    I need change angulartics2On to angulartics2On="click".

    But since this PR, in v1.1.1, we are able to use angulartics2On only, the default event will be click.