Alexander Zhidkov
Alexander Zhidkov

Reputation: 581

How to use Google Analytics with AngularFire?

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?

Upvotes: 20

Views: 12107

Answers (2)

Thierry Falvo
Thierry Falvo

Reputation: 6280

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).

Upvotes: 45

Alexander Zhidkov
Alexander Zhidkov

Reputation: 581

Support for Firebase Analytics is coming to AngularFire https://github.com/angular/angularfire/issues/2178

Upvotes: 3

Related Questions