Collecting data with Trackers and Webhooks

  1. Home
  2. Docs
  3. Collecting data with Trackers and Webhooks
  4. Trackers – collecting data from your own applications
  5. React Native Tracker
  6. Quick start guide

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:


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

npm install --save @snowplow/react-native-tracker
Code language: Bash (bash)


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

import { createTracker } from '@snowplow/react-native-tracker'; const tracker = createTracker( 'appTracker', { endpoint: COLLECTOR_URL, }, );
Code language: JavaScript (javascript)

The createTracker function takes as arguments:

  1. Required: The tracker namespace, which identifies each tracker
  2. Required: The Network configuration
  3. Optional: The Tracker Controller configuration

The optional Tracker Controller configuration has as type definition:

interface TrackerControllerConfiguration { trackerConfig?: TrackerConfiguration, sessionConfig?: SessionConfiguration, emitterConfig?: EmitterConfiguration, subjectConfig?: SubjectConfiguration, gdprConfig?: GdprConfiguration, gcConfig?: GCConfiguration }
Code language: TypeScript (typescript)

In other words, it provides a way for a fine grained tracker configuration.

As an example to create a tracker with all configurations provided (wherever applicable, the default values are shown):

const tracker = createTracker( 'appTracker', { endpoint: COLLECTOR_URL, method: 'post' }, { trackerConfig: { appId: 'my-app-id', devicePlatform: 'mob', base64Encoding: true, logLevel: 'off', applicationContext: true, platformContext: true, geoLocationContext: false, sessionContext: true, deepLinkContext: true, screenContext: true, screenViewAutotracking: true, lifecycleAutotracking: false, installAutotracking: true, exceptionAutotracking: true, diagnosticAutotracking: false }, sessionConfig: { foregroundTimeout: 1800, backgroundTimeout: 1800 }, emitterConfig: { bufferOption: 'single', emitRange: 150, threadPoolSize: 15, byteLimitPost: 40000, byteLimitGet: 40000 }, subjectConfig: { userId: 'my-user-id', networkUserId: '5d79770b-015b-4af8-8c91-b2ed6faf4b1e', domainUserId: '7cdd5ea8-b0f5-47ea-a8bb-5ec8e98cdbd6', useragent: 'some-useragent-string', ipAddress: '', timezone: 'Europe/London', language: 'en', screenResolution: [123, 456], screenViewport: [123, 456], colorDepth: 20 }, gdprConfig: { basisForProcessing: 'consent', documentId: 'my-gdpr-doc-id', documentVersion: '1.0.0', documentDescription: 'my gdpr document description' }, gcConfig: [ { tag: 'my-first-gc-tag', globalContexts: [ { schema: 'my-gc-schema-01', data: {gcData: 'some data'} }, { schema: 'my-gc-schema-02' data: {moreGCData: 'some more data'} }, ] }, { tag: 'another-gc-tag', globalContexts: [ { schema: 'my-gc-schema-03' data: {gcProp: 'some value'} }, ] } ] } );
Code language: JavaScript (javascript)

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.

If you’d like to learn more about Snowplow BDP you can book a demo with our team, or if you’d prefer, you can try Snowplow technology for yourself quickly and easily.