Deep Links & Attribution Setup

Set up refr.link domains, iOS Universal Links and clipboard handoff, Android Install Referrer and App Links

Every referral starts with a link. Invitebase owns the entire link → install → attribution loop as first-party infrastructure: you never need a MMP or third-party deep-linking account. Attribution is deterministic and Apple-compliant — no fingerprinting, ever — using the mechanism each platform actually sanctions.

For the conceptual model, read Attribution. This guide is the setup.

By default, your campaign will get it's own unique subdomain on yourCompany.refr.link, chosen in Settings → General when you create the app. Links look like:

https://mycompany.refr.link/a1b2c3

The code (a1b2c3) can be customized by each user. Opening the link records the click idempotently (creating the referral in clicked state) and renders a themed offer page: the referrer's name, the double-sided reward, a store/app CTA — and always the invite code in plain text, because manual entry is the universal fallback. Unknown or expired codes render a generic "get the app" page and create no referral.

Custom domains

To serve links from your own domain (invite.mycompany.com instead of mycompany.refr.link):

On the Invitebase dashboard, navigate to Settings → General → Custom domains, and add your domain as your preferred link domain.
To being using your domain, you will need to xreate the CNAME record at your DNS provider: invite.mycompany.com → cname.invitebase.com.
Invitebase verifies ownership, provisions and auto-renews TLS, and flips the domain to Active. Existing refr.link links keep working; new links use your domain.

A custom domain also serves your Universal Links and App Links association files, so the sections below apply unchanged — substitute your domain wherever mycompany.refr.link appears.

iOS setup

Register your app identity

In Settings → Attribution, enter your Apple Team ID and bundle ID. Invitebase generates and serves the apple-app-site-association (AASA) file for your subdomain — you never host it.

Add the Associated Domains entitlement

This is the one step only you can do — it is an OS requirement. In Xcode, under Signing & Capabilities → Associated Domains, add:

applinks:mycompany.refr.link

Enable the Associated Domains capability for your App ID in the Apple Developer portal if it is not already, then ship an app update. From then on, a tapped referral link opens your app directly with the code intact.

App.swift
import InvitebaseSDK

// At launch
Invitebase.configure("pk_live_...")

// Universal Link arrives while installed
func application(_ application: UIApplication,
                 continue userActivity: NSUserActivity,
                 restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    if let url = userActivity.webpageURL {
        Invitebase.handleInbound(url) // parses the code and applies it
    }
    return true
}

Note: Universal Links only trigger on a real user tap — JavaScript or 302 redirects do not open the app. The refr.link offer page is built around this.

Deferred attribution (fresh installs): clipboard handoff

iOS has no install referrer, so Invitebase uses a deterministic first-party clipboard handoff — no ATT consent, no permission-priming, no fingerprinting:

  1. When the invitee taps the CTA on the offer page, the page writes the invite URL to the clipboard (inside the tap gesture, as Safari requires) and hands off to the App Store.
  2. On first launch, call resolveReferral(). The SDK silently checks whether the clipboard contains a URL (detectPatterns — never prompts, never reads content), and only then surfaces a system Paste button (UIPasteControl), which shows no permission modal. The SDK only accepts URLs on your configured refr.link/custom domain — an arbitrary copied URL is never treated as a referral.
  3. If the clipboard misses or the user declines, the SDK falls back to code entry, tiered by signal: a strong "paste or enter your invite code" prompt when a URL was present but unreadable, or a soft, skippable "Have an invite code?" field otherwise — so organic users are never pestered.
First launch
let result = await Invitebase.resolveReferral()
switch result {
case .attributed(let code):
    showWelcome(for: code) // e.g. "You were invited — your free month is active"
case .needsManualEntry(let signal):
    presentCodeEntry(prominence: signal) // SDK ships a themeable default screen
case .organic:
    break
}

Resolution is one-shot: once attribution resolves, the SDK persists a flag and never touches the clipboard again. Call resolveReferral() early — clipboards are volatile — but surface any UI at a contextual onboarding moment.

Android setup

Deferred attribution: Install Referrer (automatic)

Android is the easy platform. The offer page routes invitees to the Play Store with the code in the referrer= parameter, and the Play Install Referrer API passes it through install deterministically — no prompt, no clipboard, near-100% match. The SDK recovers it on first launch:

First launch
Invitebase.configure("pk_live_...")
val result = Invitebase.resolveReferral() // reads Install Referrer once, then never again

No configuration required. The referrer string is only present for Play Store installs — sideloads fall back to manual code entry.

In Settings → Attribution, enter your package name and SHA-256 signing certificate fingerprints (include the Play App Signing certificate). Invitebase serves /.well-known/assetlinks.json on your subdomain.

Then declare the intent filter:

AndroidManifest.xml
<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="https" android:host="mycompany.refr.link" />
</intent-filter>
MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    intent?.data?.let { Invitebase.handleInbound(it) }
}

Web setup

On the web everything is first-party and simple: the offer page (or your own page) persists the code in a cookie and localStorage, with expiry aligned to the campaign's qualification window. When the referred user signs up, the Web SDK reads the stored code and attaches it to the signup event automatically:

signup.ts
import { Invitebase } from '@invitebase/js';

Invitebase.configure('pk_live_...');
Invitebase.identify({ id: user.id });
Invitebase.track('signup'); // stored referral code attached automatically

Attribution is first-click within the window, and the stored code is cleared once attribution resolves. If a user lands directly on your site with a code (e.g. from a bio link), apply it explicitly with Invitebase.applyCode(code).

How a recovered code becomes attribution

All paths converge on the same primitive: the SDK attaches referral_code to the referred user's events (POST /v1/events), and the backend binds that user to the clicked referral and advances it to signed_up. A referred user binds to at most one referral per campaign; invalid or expired codes are rejected cleanly so your UI can route back to manual entry. Self-referrals (referrer = referred user) are caught by fraud controls.

Test attribution end to end

Use test-mode keys throughout; every branch of the flow emits telemetry you can watch live.

Create a test referrer and link (see the walkthrough), and open the link on a device — the referral appears in the dashboard as clicked.
iOS: install via TestFlight, tap the CTA on the offer page (clipboard write happens here), launch, and confirm resolveReferral() returns .attributed. Test the declined path too: clear the clipboard before first launch and verify the manual-entry prompt appears. Android: use a Play internal-testing build — Install Referrer does not populate for direct APK installs.
Installed-app path: with the app already installed, tap the link and confirm it opens the app directly (long-press the link in Notes/messages to check the "Open in app" affordance). If it opens the browser instead, re-check the entitlement/intent-filter and your Team ID / fingerprints in Settings → Attribution.
Confirm the referral advanced to signed_up and check Charts → Attribution for the funnel breakdown: attributed vs manual-entry vs declined vs organic per platform.

What's next

On this page