Installation
Install the SDK and its required peer dependency:app option instead.
For Android install attribution (knowing which site or campaign a user came from before installing), also install:
iOS Setup (bare React Native only)
If you’re using bare React Native (not Expo), run pod install after adding native dependencies:Expo projects handle native linking automatically - no
pod install needed.Quick Start
Wrap your app with theFormoAnalyticsProvider:
Code examples
React Native
examples/react-native
Track screen views
Use thescreen() method to track screen views - the mobile equivalent of page views:
screen() method signature is:
Include
formo in the dependency array. The SDK initializes asynchronously, so including it ensures the screen event fires once initialization completes.page events so they flow through the same analytics as web page views. The screen name is recorded in the app:// scheme — formo.screen('Wallet') is sent with a page_url of app://Wallet, and a router-style name like formo.screen('/tabs/leaderboard') is sent as app:///tabs/leaderboard.
Formo derives the rest for you: your app becomes the equivalent of a web origin (from the app name or bundle ID in the event context), and the screen name becomes the page path — so screens appear alongside web pages in reports like Top Pages.
React Navigation
Automatically track all screen transitions:Mobile lifecycle events
The SDK automatically tracks application lifecycle events following the Segment/RudderStack specification:
Lifecycle events are enabled by default and require
asyncStorage to be provided for accurate install/update detection. To disable:
The SDK detects app version and build from
expo-application, react-native-device-info, or the app option (in that order). If none are available, version and build will be empty strings.Identify users
Callidentify() after a user connects their wallet:
When using Wagmi integration, wallet connections are automatically tracked. You only need to call
identify() manually if you want to associate additional user data or use a custom user ID.Track custom events
Track custom events with thetrack() method:
Deep link attribution
Parse UTM parameters and referral codes from deep links:- UTM parameters (
utm_source,utm_medium,utm_campaign,utm_term,utm_content) - Referral codes (
ref,referral,refcode,referrer_code)
myapp://home?utm_source=twitter&utm_campaign=launch&ref=friend123
Web-to-mobile attribution
Deep link attribution tells you where a user came from once the app is already installed. Web-to-mobile attribution answers the earlier question: which site or campaign led someone to install the app in the first place.Android
Google Play passes a referrer through the install, so this is captured reliably. Point your marketing links at your Play Store listing with areferrer parameter:
Application Installed event, and to the traffic source used by subsequent events:
react-native-play-install-referrer and a native rebuild — see Installation. The lookup runs once, on the first launch after install.
iOS
Not supported. Apple does not expose an install-referrer API, so an install cannot be attributed to a referring website from within the SDK. This requires a third-party attribution service such as Branch or AppsFlyer. On iOS this capture is a no-op — deep link attribution still works normally.
Configuration
Provider props
Example
App metadata
The SDK automatically detects app information from your app’s native configuration:app_name- from your app’s display nameapp_version- from your app’s version (e.g.,2.1.0)app_build- from your app’s build number (e.g.,42)app_bundle_id- from your bundle/package identifier
Tracking control
Control tracking behavior for different environments or chains:Autocapture
Control which wallet events are automatically captured:Attribution
Control deep link attribution and web-to-mobile attribution capture. Both sources are on by default and can be turned off individually:attribution: false disables both.
Logging
Enable debug logging during development:Ready callback
Execute code when the SDK is fully initialized:Consent management
Comply with privacy regulations using built-in consent management:Wagmi integration
When Wagmi integration is enabled, the SDK automatically tracks:Mobile context
The SDK automatically enriches every event with mobile-specific context:Session management
The SDK assigns asession_id to every event. A session groups one user’s burst of activity into a single visit, and powers the Sessions, Session duration, and Bounce rate metrics on your dashboard. No configuration is required.
This differs from the web SDK, where
session_id is derived server-side as a daily-changing value. That derivation relies on the request’s origin, IP and browser user agent — signals a native app does not provide meaningfully — so the mobile SDK supplies its own session instead.Manual event flushing
Force flush pending events (useful before app backgrounding):The SDK automatically flushes events when the app goes to background.
Verification
To verify the SDK is working:- Enable debug logging in development
- Trigger a screen view or custom event
- Check the console for event logs
- Verify events appear in the Activity page on your Formo dashboard