I'm wondering, are there any way to disable analytics auto activity tracking? I have view hierarchy based on fragments and there are few cases:
I use such a code in fragments from Firebase docs to track custom screens:
mFirebaseAnalytics.setCurrentScreen(getActivity(), "some_fragment_1", null);
In first case, I want to track only root fragment. In second case, I want to track only each fragment that becomes root. In third case, I want to track only each fragment that becomes visible in ViewPager.
And, the problem is, that I don't want to track Activities at all, but unfortunately, Firebase do it on its own - as a result of that, my statistics looks weird, like:
SomeActivity 50%
some_fragment_1 30%
some_fragment_2 20%
I dont't need activity in this statistics, because, fragment statistics already includes it.
So, is there any way to disable activity tracking?
Now it's possible with new API to manually track screens.
Can disable auto-tracking
On iOS, set FirebaseAutomaticScreenReportingEnabled to NO in your info.plist. On Android, set google_analytics_automatic_screen_reporting_enabled to false in your manifest.
Manual Tracking
iOS
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// After enough time has passed to make this screen view significant.
Analytics.logEvent(AnalyticsEventScreenView, parameters: [
AnalyticsParameterScreenName: screenName!,
AnalyticsParameterScreenClass: screenClass!,
MyAppAnalyticsParameterFitnessCategory: category!
])
}
Android
@Override
public void onResume() {
super.onResume();
// After enough time has passed to make this screen view significant.
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.SCREEN_NAME, screenName);
bundle.putString(FirebaseAnalytics.Param.SCREEN_CLASS, screenClass);
bundle.putString(MyAppAnalyticsConstants.Param.TOPIC, topic);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW, bundle);
}
https://firebase.googleblog.com/2020/08/google-analytics-manual-screen-view.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With