Installation
If you haven’t already installed React Navigation, add the core library, the native stack navigator, and the required peer dependencies:Basic Setup
Track screens with useFocusEffect
The quickest way to track a screen is to call tappd.trackScreen() inside the useFocusEffect hook. The hook fires every time the screen comes into focus, so you get an accurate view even when users navigate back to it.
Navigation Container Setup
For a centralized approach that tracks every screen transition automatically, create auseNavigationTracking helper and attach it to your NavigationContainer.
Create the navigation helper
Use the helper in App.js
Advanced: Custom Navigator
If you want tracking baked into a reusable navigator component, wrapcreateNativeStackNavigator in a TrackedStackNavigator that listens for state changes internally.
Tab Navigation
For bottom tab navigators, adduseFocusEffect inside each tab screen so tracking fires when a user switches tabs:
Tracking Navigation Events
Track explicit navigation actions — for example, when a user taps a button that takes them to another screen — by callingtappd.track() before calling navigation.navigate():
Deep Linking
The SDK automatically tracksdeep_link.opened events. For additional context — such as distinguishing between cold-start and warm-start deep links — you can supplement automatic tracking with manual calls:
Screen Tracking with Params
Pass route parameters as tracking context to enrich your analytics data:Complete Example
API Reference
| Method | Signature | Returns | Description |
|---|---|---|---|
tappd.trackScreen | (screenName: string, properties?: EventProperties) | Promise<void> | Records a screen view event. Pass properties to attach arbitrary metadata — route params, categories, or any context useful for analysis. |
EventProperties type accepts any flat or nested object of strings, numbers, or booleans.