1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Event not being registered with Umami and Angular

Discussão em 'Angular' iniciado por Eli-ott, Agosto 1, 2025.

  1. Eli-ott

    Eli-ott Guest

    So I have an Angular application. I have a component in which I (for testing of course) track an event using Umami on the ngOnInit() function and ngAfterViewInit() and both these events are appearing.

    Now I also have a tracker in a function that executes when I click something. The function executes well and I don't have any error but the event isn't registered in the dashboard.

    I console logged the umami object after each track and it is the exact same.

    I self host my umami instance and is configured properly because it can track events and it tracks page views.

    Here is my component code :

    @Component({
    selector: 'cmr-my-reservations',
    imports: [
    FullCalendarModule
    ],
    templateUrl: './my-reservations.component.html',
    styleUrl: './my-reservations.component.scss',
    })
    export class MyReservationsComponent implements OnInit, AfterViewInit {
    ngOnInit(): void {
    // @ts-ignore
    if (window.umami) {
    // @ts-ignore
    umami.track('event in init');
    // @ts-ignore
    console.log('Umami object in ngOnInit:', umami, window.umami);
    } else {
    console.error('Umami is not available in ngOnInit');
    }
    }

    ngAfterViewInit(): void {
    // @ts-ignore
    if (window.umami) {
    // @ts-ignore
    umami.track('event in reservation');
    // @ts-ignore
    console.log('Umami object in ngAfterViewInit:', umami, window.umami);
    } else {
    console.error('Umami is not available in ngAfterViewInit');
    }
    }

    public handleEventClick(event: EventClickArg): void {
    // @ts-ignore
    if (window.umami) {
    // @ts-ignore
    umami.track('open reservation');
    console.log('Tracking success');
    // @ts-ignore
    console.log('Umami object in handleEventClick:', umami, window.umami);
    } else {
    console.error('Umami is not available in handleEventClick');
    }
    }
    }

    Continue reading...

Compartilhe esta Página