Skip to main content

For AI agents: a Markdown version of this page is at https://docs.snowplow.io/docs/sources/react-native-tracker/quick-start-guide.md. The index of all documentation pages is at https://docs.snowplow.io/llms.txt, and the index for this section is at https://docs.snowplow.io/docs/cdi/llms.txt.

React Native tracker quick start guide

Snowplow Tracker Maintenance Classification: Actively Maintained Latest @snowplow/react-native-tracker version on npm Supported React Native peer dependency version range

In order to start sending events using the Snowplow React Native Tracker, the following steps are involved:

Installation​

To install the tracker, add it as a dependency to your React Native app:

bash
npm install --save @snowplow/react-native-tracker

Note that in addition to react and react-native, the tracker has two peer dependencies that need to be added as dependencies to your app:

  1. @react-native-async-storage/async-storage for event and session local storage implementation.
  2. react-native-get-random-values as a polyfill for the Crypto Web APIs.

Instrumentation​

Next, in your app create a new tracker using the newTracker method. As a minimal example:

typescript
import { newTracker } from '@snowplow/react-native-tracker';

const tracker = newTracker({
namespace: 'appTracker',
endpoint: COLLECTOR_URL,
});

The newTracker function takes the tracker configuration as the only argument. There are two required properties within the configuration:

  1. The tracker namespace, which identifies each tracker instance.
  2. The collector URL endpoint.

Track events​

Once the tracker is initialized, you can use the tracker methods to track events, about which you can find out more in the following Tracking events section. As an example, you can track a screen view event like this:

ts
tracker.trackScreenViewEvent({
name: 'my-screen-name',
id: '5d79770b-015b-4af8-8c91-b2ed6faf4b1e',
type: 'carousel',
transitionType: 'basic'
});

Was this page helpful?