Count page invocations

Hi, I want to count the invocation of page within an ember app which means every time the user navigates to a new page (via link-to) the system should increment a counter for this page. My problem is that I have no idea on how to implement this behaviour. Any helpis appreciated :slight_smile:

Hi Marco, the route service has a routeDidChange event. Maybe this helps.

// app/routes/application.js
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class ApplicationRoute extends Route {
  @service router;

  constructor() {
    super(...arguments);

    this.router.on('routeDidChange', () => {
      const page = this.router.currentURL;
      const title = this.router.currentRouteName
    });
  }
}
1 Like

Hi Christoph, the Route class has a method โ€œactivateโ€ which did the job. Your solution seems to be an alternative. Thx :slight_smile: