To add Forage to your project just run the following command, please note Forage uses peer dependencies of other well-known packages in order to give you the best experience:
yarn add react-native-forage @react-native-async-storage/async-storage @react-native-community/netinfo react-native-device-info react-native-localize
If you use npm instead of yarn
npm i react-native-forage @react-native-async-storage/async-storage @react-native-community/netinfo react-native-device-info react-native-localize
If you are using a React Native version less than 0.60:
react-native link @react-native-async-storage/async-storage @react-native-community/netinfo
To obtain a unique app key, simply sign up at app.forage-analytics.com.
Once you have obtained an app key, you can connect your application to Forage and start tracking events via the start method, passing in your app key and the React Native AppState API.
Import package + Dependency
import Forage from 'react-native-forage';
import { AppState } from 'react-native';
Call Forage.start with your unique app key.
TIP: Don’t forget to pass in AppState
Forage.start(YOUR_APP_KEY_HERE, AppState);
The Forage SDK consists of 5 additional methods;
Sets a unique User ID for a session.
Example:
Forage.setUserId('User1');
Send up any data of any size. Properties are optional.
Examples:
trackEvent('Customer Checkout Press');
trackEvent('Item Added to Basket', {
label: 'Dining Room Chair',
currency: '£',
cost: '99.99',
discount: '10%',
total: '90.00'
});
Track screen changes inside of your application.
Examples:
trackScreen('Product A – View');
trackScreen('Checkout Screen');
These can be used together to allow you to track the time that a particular event or action took to complete.
Examples:
startTimer('API X Called');
const data = await callApi();
endTimer('API X Called');
Simply fill in the form or email us and our experts will get in touch within 1 working day and advise you on how Forage can help.