Simple instructions to get you started

  • 01Installation
  • 02Integration
  • 03Forage SDK - Optional Methods

01Installation

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

02Integration

Obtaining an app key

To obtain a unique app key, simply sign up at app.forage-analytics.com.

Call Forage.start

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);

03Forage SDK - Optional Methods

The Forage SDK consists of 5 additional methods;

Forage.setUserId(userId: string)

Sets a unique User ID for a session.

Example:

Forage.setUserId('User1');

Forage.trackEvent(eventName: string, properties?: string | number | boolean | object)

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'
});

Forage.trackScreen(screenName: string)

Track screen changes inside of your application.

Examples:

trackScreen('Product A – View');
trackScreen('Checkout Screen');

Forage.addTimer(label: string) & Forage.endTimer(label: string)

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');

Want a personalised demo?
Fill in the form below.

Request a demo

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.

hello@forage-analytics.com