Skip to main content

Prerequisites

Before you get started, make sure you have the following:
  1. Obtain your publishable key (DUB_PUBLISHABLE_KEY) from your workspace’s Tracking settings page.
  2. You would also want to have your custom domain (DUB_DOMAIN) handy as well.
  3. (Optional) If you plan to track conversions, make sure to enable conversion tracking for your links.

Quickstart

This quick start guide will show you how to get started with Dub React Native SDK in your React Native app.
1

Install the Dub React Native SDK

2

Initialize the SDK

You must call init on your dub instance with your publishable key and domain prior to being able to use the dub instance. We provide two ways to initialize the SDK:Option 1: Use the DubProvider to wrap your app
Option 2: Manually initialize the Dub SDK
3

Track deep link open events

Call trackOpen on the dub instance to track deep link and deferred deep link open events. The trackOpen function should be called once without a deepLink parameter on first launch, and then again with the deepLink parameter whenever the app is opened from a deep link.
If your iOS app uses third-party SDKs that handle URLs (e.g., Facebook/Meta SDK), make sure your AppDelegate’s openURL: handler doesn’t short-circuit with ||. When a third-party SDK returns YES first, RCTLinkingManager never fires and trackOpen won’t be called. See the troubleshooting guide for details and a fix.
React Native
4

Track lead events (optional)

To track lead events, call trackLead on the dub instance with your customer’s external ID, name, and email.
React Native
Here are the properties you can include when sending a lead event:
5

Track sale events (optional)

To track sale events, call trackSale on the dub instance with your customer’s user ID and purchase information.
React Native
Here are the properties you can include when sending a sale event:

Examples

Here are some open-source code examples that you can reference:

React Native

See the full example on GitHub.