Deep Linking

Deferred Deep Linking on Android: The Play Install Referrer Guide

Install₹499

On Android you don't have to guess which link brought a user in. Google Play hands your app a referrer string after the install. We read it in our own React Native SDK, so this is the version of the guide we wanted when we started: the Play Store link, the code that reads it, App Links for people who already have the app, and what a test install really returns.

How deferred deep linking works on Android

  1. Your link sends the user to the Play Store with a referrer parameter, for example link_id=abc123.
  2. The user installs the app. Google Play stores the referrer string for that install.
  3. On the first app open, your app asks Google Play for it through the Play Install Referrer API.
  4. The app reads link_id, looks up where it should go, and opens that screen.

The referrer comes from Google Play itself, so the match is exact. iOS has nothing like it: the App Store passes nothing, and link services match the first open to the click on their own side (see the iOS guide). The deferred deep linking overview explains both platforms.

Add a referrer parameter to the normal Play Store URL. Its value is a URL-encoded query string, so = becomes %3D and & becomes %26:

https://play.google.com/store/apps/details?id=com.example.shop&referrer=link_id%3Dabc123%26utm_source%3Dinstagram

Keep the value short and put an id in it rather than the full destination. An id lets you change where the link goes later and keeps personal data out of the URL. The free Play Store referrer link builder does the encoding for you.

Step 2: Read the referrer on the first app open

Add Google's Install Referrer library:

// android/app/build.gradle
dependencies {
  implementation "com.android.installreferrer:installreferrer:2.2"
}

Then read the referrer once, on the first launch after install:

// Read the install referrer once, on the first app open
val prefs = context.getSharedPreferences("deeplink", Context.MODE_PRIVATE)
if (!prefs.getBoolean("referrer_checked", false)) {
  val client = InstallReferrerClient.newBuilder(context).build()
  client.startConnection(object : InstallReferrerStateListener {
    override fun onInstallReferrerSetupFinished(code: Int) {
      if (code == InstallReferrerClient.InstallReferrerResponse.OK) {
        val details = client.installReferrer
        val referrer = details.installReferrer      // "link_id=abc123&utm_source=instagram"
        val clickedAt = details.referrerClickTimestampSeconds
        val installedAt = details.installBeginTimestampSeconds
        handleReferrer(referrer, clickedAt, installedAt)
      }
      // OK or not, don't ask again on the next launch
      prefs.edit().putBoolean("referrer_checked", true).apply()
      client.endConnection()
    }
    override fun onInstallReferrerServiceDisconnected() {
      // Play Store service went away: try again on the next app start
    }
  })
}

Besides the referrer string you get the time of the link click and the time the install began. Both help you spot old or suspicious attributions, for example a click from weeks before the install.

What the referrer looks like

How the app was installedWhat installReferrer returns
From your Play Store linkYour decoded value, e.g. link_id=abc123&utm_source=instagram
Searched or browsed the Play Storeutm_source=google-play&utm_medium=organic
Not from Google Play (Android Studio, adb, an APK, another store)Not your referrer. On our Android 16 test phone, a debug build installed from Android Studio got utm_source=google-play&utm_medium=organic with the click and install times both 0. Other devices can return an error code instead.

Step 3: Route the user

fun handleReferrer(referrer: String, clickedAt: Long, installedAt: Long) {
  val params = Uri.parse("https://x/?$referrer")   // reuse Uri's query parser
  val linkId = params.getQueryParameter("link_id") ?: return  // organic install: normal onboarding
  // Ask your backend (or link provider) where link_id should go, e.g. "/product/42"
  openScreenFor(linkId)
}

Always plan for “no match”: most installs are organic, and those users should get your normal onboarding. If the screen needs a signed-in user, keep the destination and open it right after sign-up instead of dropping it.

The referrer only helps new installs. For people who already have the app, the same campaign link should open it directly. That's what Android App Links do: a normal https:// link opens your app instead of the browser once Android has verified that you own the domain. Publish an assetlinks.json file:

// https://example.com/.well-known/assetlinks.json
[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.example.shop",
    "sha256_cert_fingerprints": ["AB:CD:...:EF"]
  }
}]

and add a verified intent filter:

<!-- AndroidManifest.xml, inside your launcher activity -->
<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="example.com" android:pathPrefix="/l/" />
</intent-filter>

Check the result on a device:

adb shell pm get-app-links com.example.shop
# "example.com: verified" means Android will open your app for these links

If you use Play App Signing, the fingerprint in assetlinks.json must be the app signing key from Play Console, not your upload key. That mismatch is the most common reason App Links open the browser in production while working in debug builds. The App Links generator builds both files for you.

React Native and Flutter

  • React Native: the react-native-install-referrer package exposes the same referrer string to JavaScript. Read it in your first-launch logic and route with your navigation library.
  • Flutter: use a Play Install Referrer plugin or a small platform channel that runs the Kotlin code above and returns the string to Dart.
  • In both cases, set up App Links in the native Android project, exactly as in step 4.

How to test deferred deep linking on Android

A build installed from Android Studio won't tell you much: ours read the default organic value with zero timestamps, because Google Play has no record of that install. To see a real referrer, install the way users do:

  1. Upload a build to an internal testing track in Play Console and add your Google account as a tester.
  2. Uninstall the app from the test phone.
  3. Open your Play Store link with the referrer on that phone and install the app from Google Play.
  4. Open the app and check that it lands on the right screen. Log the raw referrer string while testing.
  5. Repeat with no referrer (install from a Play Store search) and confirm the user gets normal onboarding.

Why deferred deep linking fails on Android

What you seeLikely cause
Always the organic stringA redirect or link shortener dropped the referrer parameter, or it wasn't URL-encoded. Open the final Play Store URL and check it's still there.
Works once, then never again on the same phoneThe referrer is fixed per install. Uninstall and reinstall from the link for each test.
Organic string with click and install time 0The build didn't come from Google Play (Android Studio, adb or an APK).
Link opens the browser instead of the appApp Links aren't verified: wrong fingerprint (upload key instead of the app signing key), missing autoVerify, or assetlinks.json not served from /.well-known/.
User lands on the right screen, then gets sent to login and loses itStore the destination and open it after sign-in instead of on the first screen.

TrackerLink creates the campaign links, sends Android users to the Play Store with the referrer attached, and counts clicks. The notifySphere React Native SDK reads the install referrer on the first launch and saves the TrackerLink click and campaign in the user's tags, so installs and later events like sign-ups show up per campaign. See the TrackerLink docs and the React Native SDK. If you're moving off Firebase Dynamic Links, the migration checklist covers what to replace.

Frequently asked questions

How long is the install referrer available on Android?

Google Play keeps the install referrer for 90 days after the install, and it doesn't change unless the app is reinstalled. Read it on the first app open anyway, because that's when you can still route the user to the right screen.

Why does my app get utm_source=google-play&utm_medium=organic?

That's what Google Play returns when the install didn't come through a Play Store link with your referrer parameter, for example when someone searched the Play Store for your app. It can also mean a redirect along the way dropped the referrer parameter, so test your link end to end.

Does deferred deep linking work for apps installed outside Google Play?

Not with the Play Install Referrer API. It only knows about installs from Google Play. Builds from elsewhere don't get your referrer: in our test, a debug build got the default organic string with zero timestamps. Treat those installs as organic, or use the other store's own referrer mechanism.

Do I still need Firebase Dynamic Links for this?

No, and you can't use them anyway: Google shut Firebase Dynamic Links down in August 2025. On Android the referrer parameter plus App Links covers both new and existing users. You need a link service only if you want click tracking, campaign reports and iOS matching in one place.