I have an Angular app build with AngularFire and hosted on Firebase. How should I be using Analytics SDK to set the user ID, track page loads and log custom events?
How to use Google Analytics with AngularFire?
This blog could be helpful: arunraj6.medium.com/… –
Solenne
AngularFire is now supporting Firebase Analytics since version 5.3.0.
You can update your dependencies :
"@angular/fire": "^5.2.3",
"firebase": "^7.8.0"
As mentioned by AngularFire Docs, you just have to add AngularFireAnalyticsModule
:
import { AngularFireAnalyticsModule } from '@angular/fire/analytics';
@NgModule({
imports: [
AngularFireModule.initializeApp(environment.firebase),
AngularFireAnalyticsModule
]
})
export class AppModule { }
Be sure to add your appId
and measurementId
to your config file. (retrieve from Firebase Console, after enabling Analytics).
Run npm -v @angular/fire and nom -v firebase to check your current version installed –
Toffic
In later versions of AngularFire
AngularFireAnalyticsModule
moved to @angular/fire/compat/analytics
. –
Titfer @MikePoole do you know if there is none compat import that we should be using instead now? I see there is a
import { AnalyticsModule } from "@angular/fire/analytics";
available now. –
Petitioner Support for Firebase Analytics is coming to AngularFire https://github.com/angular/angularfire/issues/2178
© 2022 - 2025 — McMap. All rights reserved.