React Native SDK
Add install and purchase attribution to your React Native app with a single npm package.
Prerequisites
- React Native 0.70 or later
- An Instally account with an App ID and API Key (available at app.instally.io)
Step 1: Install the package
Install the Instally React Native package from GitHub:
Terminal
npm install github:Instally-io/instally-react-native-sdk @react-native-async-storage/async-storageIf you use Yarn:
Terminal
yarn add https://github.com/Instally-io/instally-react-native-sdk.git @react-native-async-storage/async-storageiOS: run pod install
After installing the package, run
cd ios && pod install to link the native iOS dependency.Android: rebuild the native app
The React Native SDK includes a small native Android module for Google Play Install Referrer. After installing or upgrading the package, rebuild your Android dev build so the native module is included.
Step 2: Configure and track install
Initialize the SDK in your app's root component or entry point. Replace the placeholder values with the App ID and API Key from your Instally dashboard.
App.tsx (functional component)
App.tsx
import React, { useEffect } from 'react';
import { instally } from 'instally-react-native';
function App() {
useEffect(() => {
async function initInstally() {
instally.configure({ appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY' });
await instally.trackInstall();
}
initInstally();
}, []);
return (
// Your app content
);
}
export default App;index.js (entry point)
index.js
import { AppRegistry } from 'react-native';
import { instally } from 'instally-react-native';
import App from './App';
import { name as appName } from './app.json';
instally.configure({ appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY' });
instally.trackInstall();
AppRegistry.registerComponent(appName, () => App);Step 3: Track purchases (optional)
To attribute revenue to referrers, call trackPurchase() after every successful in-app purchase.
PurchaseHandler.tsx
import { instally } from 'instally-react-native';
async function handlePurchase(purchase: Purchase) {
// After verifying the purchase was successful:
await instally.trackPurchase({
productId: purchase.productId,
revenue: 9.99,
currency: 'USD',
transactionId: purchase.transactionId,
});
}Works with any IAP library
The Instally SDK is compatible with popular in-app purchase libraries like
react-native-iap and expo-in-app-purchases. Just call trackPurchase() after a successful transaction from any library.Important notes
No special permissions required
The Instally SDK does not use IDFA on iOS or advertising IDs on Android. No ATT prompt is needed.
Testing development builds
Development builds are supported. On Android, deterministic matching requires a Google Play install path that supplies the Play Install Referrer, such as internal testing or internal app sharing. Direct APK/ADB installs can run the SDK but may return no match because Google Play did not pass a referrer to the app. For the cleanest attribution test, use one fresh click on the same physical device you open the app on, install through Play, then launch the app within a few minutes. If you retry on the same installed dev build, uninstall/reinstall the app or call
instally.resetForTesting() in development before calling trackInstall().trackInstall()is safe to call on every app launch. It only fires once per install.trackPurchase()should be called after every successful in-app purchase.- AsyncStorage is the only peer dependency. In bare React Native apps, run
cd ios && pod installafter installing. - Works alongside any other analytics or attribution provider.