Skip to main content

Quick start guide

Tracker Maintenance Classification Latest tracker version Supported React Native versions

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:

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

Instrumentation

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

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:

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