Make sure Firebase is giving you real user data
When you’re developing and you’re trying out internal builds, there is a risk of contaminating the reporting data with your own internal actions.
Let’s say you’re adding a new in-app purchase and buying the item logs an event to Firebase Analytics. When you’re testing and you try to purchase the item (to see if it works), unfortunately the event will be logged to Firebase, even though these are your actions and not your users’. Surely you don’t want this. You want to only see data from production builds.
Here are some of the ways you could try to resolve an issue like this:
1. Use DebugView
You could enable Analytics debug mode. If we’re using the Android emulator:
adb shell setprop debug.firebase.analytics.app <package_name>
Now when we start our app in the emulator, we can go to the DebugView
section of the Firebase Console and see events logged from the virtual device in realtime.
Note: This method is recommended by the Firebase team. You can get more info about it at https://support.google.com/analytics/answer/7201382.
2. SetAnalyticsCollectionEnabled()
You could also attempt to resolve this issue by using FirebaseAnalytics.SetAnalyticsCollectionEnabled(false)
at the starting point of your app.
It seems though that Firebase Analytics still logs at least a few events (like first_open
), and I was recorded as a daily active user when I tried this. Perhaps it takes a few seconds for Analytics to be fully disabled and in that time it logged some of those events that are usually recorded first when the user opens the app.
3. Block the Android emulator
Another way is by using a firewall software to prevent the Android emulator from connecting to the web. But then there will be times when you’ll need to test functionality requiring internet access.
4. Log an event in internal builds
Instead of trying to disable Analytics when creating an internal build for testing, we can log a custom internal_user
event depending on whether a flag indicating an internal build is set.
InternalBuild.Instance.internalBuild
is a component property that I can set from the Unity editor:
The InternalBuild
component also has a Banner
property which takes a game object in the scene and makes visible or not, depending on whether or not its Internal Build
flag is set.
By doing this we can create an audience in the Audiences
section of Firebase Console (which we can name “Production”) that excludes the group of users that has the event logged.
After creating the audience we can now apply it to the dashboard:
Of course if we still want to see any data generated by internal testing we can always remove the filter.
Now we can be more certain of the data we’re getting from our real end users.
A downside of this method is that not all Analytics data can be filtered. Our Production
filter won’t be able to filter out internal users from the retention data in our dashboard, for example.
Do you have a better way of filtering out development activity from Analytics? Please share by leaving a reply.