Screen tracking
Track page transitions in your Ionic app so Screeb can evaluate URL-based and page-level targeting rules for messages and surveys.
Automatic trackingโ
Screeb automatically detects URL changes in the browser. For most use cases, no additional setup is needed โ navigation events update window.location, which Screeb monitors.
Manual event tracking per routeโ
If you want to trigger specific Screeb events on route transitions, subscribe to the Angular Router events used by Ionic:
import { Component } from "@angular/core";
import { Router, NavigationEnd } from "@angular/router";
import { filter } from "rxjs/operators";
import { ScreebService } from "@screeb/sdk-angular";
@Component({ selector: "app-root", template: "" })
export class AppComponent {
constructor(private router: Router, private screeb: ScreebService) {
this.router.events
.pipe(filter((event) => event instanceof NavigationEnd))
.subscribe((event: NavigationEnd) => {
this.screeb.eventTrack("page_viewed", { path: event.urlAfterRedirects });
});
}
}