Docs
v2.0
Title
Message
Create new category
What is the title of your new category?
Edit page index title
What is the title of the page index?
Edit category
What is the new title of your category?
Edit link
What is the new title and URL of your link?
Mobile attribution
Copy Markdown
Open in ChatGPT
Open in Claude
This guide walks through how to set up mobile app referral attribution.
This guide explains how to add referral tracking capabilities to your existing attribution links without creating new ones. In this guide, we’ll use Branch.io as an example.
Overview
The referral flow works as follows:
- Existing user shares their unique referral link
- New user clicks the link and is directed to app store
- New user installs and opens the app
- App receives referral data and attributes the installation
- Backend records the referral during signup
Basic Concept
Instead of creating new links for each referrer, you'll append referral data to your existing Branch.io app install link:
Unset
xxxxxxxxxxOriginal: https://yourbrand.app.link/abc123With Referral: https://yourbrand.app.link/abc123?referral_ucc=A1B2CData Persists Through Installation
When a user clicks the referral link, Branch.io stores the referral data (including the referral_ucc) in their servers and associates it with the user's device fingerprint. This allows the data to persist through:
- App Store redirect
- App download
- First app launch
Data Flow Sequence
Link Click
Unset
xxxxxxxxxxhttps://yourbrand.app.link/abc123?referral_ucc=A1B2C↓Branch.io captures and stores:- referral_ucc: A1B2C- Device fingerprint- Click timestampApp Installation
Unset
xxxxxxxxxxUser installs app from store↓Branch SDK initializes on first launch↓Branch matches device to stored click data↓Delivers referral data to appAccessing Referral Data in Your App
iOS Implementation
Swift
xxxxxxxxxximport Branch class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { Branch.getInstance().initSession(launchOptions: launchOptions) { (params, error) in // Check if the user came from a Branch link if let clickedBranchLink = params?["+clicked_branch_link"] as? Bool, clickedBranchLink { // Extract referral code if let referralCode = params?["referral_ucc"] as? String { print("Referral Code: \(referralCode)") // Store for use during signup UserDefaults.standard.set(referralCode, forKey: "pending_referral_code") } } } return true }}Android Implementation
Kotlin
xxxxxxxxxxclass MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) Branch.getAutoInstance(this).initSession({ branchUniversalObject, linkProperties, error -> if (error == null) { // Check if user came from Branch link if (linkProperties?.has("+clicked_branch_link") == true) { // Get referral code val referralCode = linkProperties.get("referral_ucc") referralCode?.let { Log.d("Branch", "Referral Code: $it") // Store for signup getSharedPreferences("app_prefs", Context.MODE_PRIVATE) .edit() .putString("pending_referral_code", it) .apply() } } } }, this.intent.data, this) }}React Native Implementation
Javascript
xxxxxxxxxximport branch from 'react-native-branch'; function DeepLinkHandler() { useEffect(() => { // Handle deep link when app is already running const subscription = branch.subscribe({ onNewIntent: ({ error, params, uri }) => { if (error) { console.error('Branch link error:', error); return; } if (params['+clicked_branch_link']) { handleDeepLink(params); } } }); return () => subscription(); }, []); const handleDeepLink = async (params) => { const referralCode = params.referral_ucc; if (referralCode) { await AsyncStorage.setItem('pending_referral_code', referralCode); // Handle navigation or other logic based on deep link } }; return null;}Using the Referral Data During Signup
When the user completes signup, retrieve the stored referral code and include it in your signup API call:
iOS Implementation
Swift
xxxxxxxxxx// iOS Exampleclass SignupViewController: UIViewController { func completeSignup(email: String, password: String) { // Get stored referral code let referralCode = UserDefaults.standard.string(forKey: "pending_referral_code") // Include in signup API call let signupData = [ "email": email, "password": password, "referral_code": referralCode ] api.signup(signupData) { result in if result.success { // Clear stored referral data after successful signup UserDefaults.standard.removeObject(forKey: "pending_referral_code") } } }}Android Implementation
Kotlin
xxxxxxxxxx// Android Exampleclass SignupActivity : AppCompatActivity() { private fun completeSignup(email: String, password: String) { val prefs = getSharedPreferences("app_prefs", Context.MODE_PRIVATE) val referralCode = prefs.getString("pending_referral_code", null) val signupData = HashMap<String, String>().apply { put("email", email) put("password", password) referralCode?.let { put("referral_code", it) } } api.signup(signupData) { success -> if (success) { // Clear stored referral data prefs.edit().remove("pending_referral_code").apply() } } }}React Native Implementation
Javascript
xxxxxxxxxxfunction SignupScreen({ navigation }) { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const handleSignup = async () => { try { const referralCode = await AsyncStorage.getItem('pending_referral_code'); const response = await api.signup({ email, password, referral_code: referralCode }); if (response.success) { await AsyncStorage.removeItem('pending_referral_code'); navigation.navigate('Home'); } } catch (error) { console.error('Signup error:', error); } }; return ( // Your signup form JSX );}VariableType to search · ESC to discard
GlossaryType to search · ESC to discard
InsertType to search · ESC to discard
No matches
Last updated on
Was this page helpful?
Next to read:
Partner Overviewnull
Discard Changes
Do you want to discard your current changes and overwrite with the template?
Archive Synced Block
Message
Create new Template
What is this template's title?
Delete Template
Message
On This Page
Mobile attributionOverviewBasic ConceptData Persists Through InstallationData Flow SequenceAccessing Referral Data in Your AppUsing the Referral Data During SignupLink ClickApp InstallationiOS ImplementationAndroid ImplementationReact Native ImplementationiOS ImplementationAndroid ImplementationReact Native Implementation