I’m looking at understanding the best way to measure screenviews in my iOS/Android app using @capacitor-community/firebase-analytics
.
From reading the Firebase docs (Measure screenviews | Google Analytics for Firebase), it looks like Firebase automatically tracks screenviews, much like GA measures page titles.
With that, does that mean that the setScreenName
method in the plugin is not required?
Bonus points: If our app has logins with users, what the best way to track that type of data?
Hi @yellowkicks,
this is how I track screenviews in my app:
private initFirebaseEvents() {
try {
if (this.platform.is('capacitor')) {
FirebaseAnalytics.setCollectionEnabled({
enabled: environment.production,
});
this.router.events.pipe(
filter((e: RouterEvent) => e instanceof NavigationEnd),
).subscribe((e: RouterEvent) => {
FirebaseAnalytics.setScreenName({
screenName: e.url // Example: "/news/abc-xyz/"
});
});
}
} catch (e) {
console.error(e);
}
}
To track logins I would use the logEvent()
method.
Regards,
Marius
@mariusbolik this is a very similar approach I have been taking. Instead of sending the URL to Firebase with each route change, is there a way to send the page title?