Skip to main content
Tappd works seamlessly alongside React Navigation — the most popular navigation library for React Native — to give you automatic screen-level analytics without wiring up tracking calls on every screen manually. You can use a lightweight hook-based approach for individual screens, or set up a centralized navigation tracker that fires on every route change.

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.
For a centralized approach that tracks every screen transition automatically, create a useNavigationTracking 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, wrap createNativeStackNavigator in a TrackedStackNavigator that listens for state changes internally.
Use it just like the standard stack navigator:

Tab Navigation

For bottom tab navigators, add useFocusEffect 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 calling tappd.track() before calling navigation.navigate():

Deep Linking

The SDK automatically tracks deep_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

The EventProperties type accepts any flat or nested object of strings, numbers, or booleans.

Best Practices

Follow these patterns to get the most reliable screen tracking data across your app:
  • Use useFocusEffect over useEffectuseEffect only fires on mount, while useFocusEffect fires every time the screen gains focus, giving you accurate revisit counts.
  • Always track with context — Pass relevant route params (product IDs, category names, etc.) so your analytics have enough detail to be actionable.
  • Use consistent screen names — Pick a naming convention and stick with it. Inconsistent names (e.g., "home" vs. "HomeScreen" vs. "Home") fragment your funnel data.
  • Track explicit navigation actions — Supplementing automatic screen tracking with event-level tracking (e.g., navigation.button_pressed) gives you a complete picture of user intent.
  • Handle deep links — Even though the SDK auto-tracks deep_link.opened, adding source context (cold_start vs. warm_start) helps attribute acquisition correctly.