Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 610
Alexander Zhidkov Avatar asked Oct 19 '19 07:10

Alexander Zhidkov


People also ask

How do I add Google Analytics to react native app?

click below link to go to Google Analytics and login. after login, click Admin menu on the left bottom of the screen. click + Create Account on the left top of the screen. insert your RN(react native) app information and click Get Tracking ID on the bottom of the screen.


Video Answer


2 Answers

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

like image 183
Thierry Falvo Avatar answered Oct 19 '22 15:10

Thierry Falvo


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

like image 3
Alexander Zhidkov Avatar answered Oct 19 '22 16:10

Alexander Zhidkov