This example shows how to do screen tracking and send to Google Analytics. The approach can be adapted to any other analytics SDK.
Listening to State Changes
Most users can use
onNavigationStateChange to track the screen. If you manually control the top-level navigator (if you have integrated redux), this will not work for you.
Screen tracking with Redux
When using Redux, we can write a Redux middleware to track the screen. For this purpose,
we will reuse
getActiveRouteName from the previous section.
Create Redux store and apply the above middleware
screenTracking middleware can be applied to the store during its creation. See Redux Integration for details.