Skip to Content
Developer DocsConceptsDeep LinksDeep link attribution

// snippet import removed // snippet import removed // snippet import removed // snippet import removed // snippet import removed // snippet import removed // snippet import removed // snippet import removed

📝

Deep link attribution requires a Business plan  subscription or higher.

Dub’s powerful attribution platform lets you understand how well your deep links are translating to actual users and revenue dollars inside your app.

Conversion analytics

📝

This feature is currently only available for iOS (Swift) and React Native. Android (Kotlin) support is coming soon. If you’d like early access, please contact us .

Prerequisites

Then, you’ll need generate a publishable key from your Dub workspace to track conversions on the client-side.

To do that, navigate to your workspace’s Tracking settings page  and generate a new publishable key under the Publishable Key section.

Enabling conversion tracking for a workspace

Once these are set up, we can start tracking conversion events for your deep links.

Step 1: Install the client-side Mobile SDK

Install the Dub React Native SDK and initialize it with your publishable key and short link domain.

Once the SDK has been initialized, you can start tracking deep link and deferred deep link 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.

import { useState, useEffect, useRef } from "react"; import { Linking } from "react-native"; import AsyncStorage from "@react-native-async-storage/async-storage"; import dub from "@dub/react-native"; export default function App() { useEffect(() => { dub.init({ publishableKey: "<DUB_PUBLISHABLE_KEY>", domain: "<DUB_DOMAIN>", }); // Check if this is first launch const isFirstLaunch = await AsyncStorage.getItem("is_first_launch"); if (isFirstLaunch === null) { await handleFirstLaunch(); await AsyncStorage.setItem("is_first_launch", "false"); } else { // Handle initial deep link url (Android only) const url = await Linking.getInitialURL(); if (url) { await handleDeepLink(url); } } const linkingListener = Linking.addEventListener("url", (event) => { handleDeepLink(event.url); }); return () => { linkingListener.remove(); }; }, []); const handleFirstLaunch = async ( deepLinkUrl?: string | null | undefined, ): Promise<void> => { try { const response = await dub.trackOpen(deepLinkUrl); const destinationURL = response.link?.url; // Navigate to the destination URL } catch (error) { // Handle error } }; // Return your app... }

If the deep link was successfully resolved and correlated to the original click, the response object will contain the destination URL, which you can use to navigate the user to the appropriate screen.

It will also contain the clickId, which the dub instance will persist internally.

Step 3: Track conversion events

You may track conversion events directly in your app with the trackLead and trackSale methods.

import dub from "@dub/react-native"; function trackLead(user: User) { try { await dub.trackLead({ eventName: "User Sign Up", customerExternalId: user.id, customerName: user.name, customerEmail: user.email, }); } catch (error) { // Handle sale tracking error } } function trackSale(user: User, product: Product) { try { await dub.trackSale({ customerExternalId: user.id, amount: product.price.amount, currency: "usd", eventName: "Purchase", }); } catch (error) { // Handle sale tracking error } }

Alternatively, you can track conversion events server-side by sending the clickId resolved from the deep link to your backend and then calling off to either:

Step 4: View your conversions

Once you’ve enabled conversion tracking for your links, all your tracked conversions will show up on your Analytics dashboard . We provide 3 different views to help you understand your conversions: