1.7 KiB
1.7 KiB
AngularFire ❱ Developer Guide ❱ Analytics
Analytics
Google Analytics is an app measurement solution, available at no charge, that provides insight on app usage and user engagement.
Dependency Injection
As a prerequisite, ensure that AngularFire
has been added to your project via
ng add @angular/fire
Provide a Google Analytics instance in the application's NgModule
(app.module.ts
):
@NgModule({
declarations: [
...
],
imports: [
...
// App initialization
provideFirebaseApp(() => initializeApp(environment.firebase)),
provideAnalytics(() => getAnalytics())
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
In your component class, for example user-profile.component.ts
import and inject Firestore
:
import { Component, inject } from '@angular/core';
import { Analytics } from '@angular/fire/analytics';
@Component({
standalone: true,
selector: 'app-user-profile',
...
})
export class UserProfileComponent {
private analytics: Analytics = inject(Analytics);
...
}
Firebase API
The Firebase API for Google Analytics documentation is available on the Firebase website.
Services
ScreenTrackingService
Coming soon, for now please review the documentation
UserTrackingService
Coming soon