Reputation: 63
First of all, apologies if this as a totally silly question, as I haven't really used Google Analytics before nor Angular.
The problem is that no analytics events (neither custom events nor the automatically generated screen_views) show up on Firebase. They do show, however, in Chrome with the GA Debug tool. I've also tried this without the debug mode enabled to no avail. Nothing can be seen in any of the Firebase (or Analytics) views, including DebugView.
Here's a sample from the browser console:
Screenshot from Chrome console with GA Debug output
Here's the relevant code. The event logging function is accessed by the components via an injected DatabaseService.
In a service feature module:
...
import { AngularFireModule } from '@angular/fire';
import { AngularFirestore } from '@angular/fire/firestore';
import { AngularFireAnalyticsModule,
ScreenTrackingService,
DEBUG_MODE } from '@angular/fire/analytics';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { DatabaseService } from './database.service';
@NgModule({
imports: [
CommonModule,
AngularFireModule.initializeApp(environment.firebase),
AngularFireAnalyticsModule,
AngularFirestoreModule,
],
providers: [
AngularFirestore,
ScreenTrackingService,
DatabaseService,
{ provide: DEBUG_MODE, useValue: true },
],
})
export class DatabaseModule {}
Logging function in DatabaseService:
...
import { AngularFirestore,
DocumentData,
DocumentSnapshot,
QuerySnapshot } from '@angular/fire/firestore';
import { AngularFireAnalytics } from '@angular/fire/analytics';
import * as firebase from 'firebase/app';
import 'firebase/firestore';
...
@Injectable({
providedIn: 'root'
})
export class DatabaseService {
constructor(
private firestore: AngularFirestore,
private analytics: AngularFireAnalytics,
) {}
...
public logEvent(eventName: string, eventParams: any = {}): void {
this.analytics.logEvent(eventName, eventParams);
}
...
Logging example in a component that uses DatabaseService:
this.databaseService.logEvent('candidate_show', {id: '6_25'});
Any help would be greatly appreciated. I already scoured through similar questions and tried the following with no help:
Upvotes: 3
Views: 2439
Reputation: 1
This is known issue of angular-fire and it is still open so please revert back to @angular/[email protected] you will able to see the data in firestore.
Upvotes: 0
Reputation: 999
This is a known issue with the latest version of AngularFire. Reverting to version 6.0.0 will fix the issue. However, that version has some issues with Firebase Auth, so if you are using Auth as well, I suggest reverting to the latest 5.x version
Upvotes: 3