Skip to content

Screen Tracking

coryzoon edited this page Feb 20, 2024 · 1 revision

How screens are tracked in Google Analytics

The mobile app uses the "@react-native-firebase/analytics" package to send analytics to Firebase. By default it does send screen tracking information but the information is not very helpful. For example it sends screen names like "RNSScreen" and "UIAlertController".

To send more valuable information the mobile app employs the following tactics:

  • In RootNavigator.js there is a function onStateChange that is called whenever there is a navigation from screen to screen. It calls a function gaTrackScreen(newRoute) where newRoute is the screen that is being navigated to.
  • In gaTrackScreen it will attempt the following logic: If the route is a classifier i.e. "QuestionClassifier" it will track the screen name as the project slug like "msbrhonclif/science-scribbler-placenta-profiles". If the route is a project list i.e. "Biology" it will track the screen name as "Project List - Biology". If none of these conditions apply it will use a title cased version of the route name as the screen name.

When testing, keep in mind that it takes a while for the screen tracking events to show up in Google Analytics. I typically wait until the next day to verify they are correct but at a minimum it could take quite a few hours for them to show up.