Deferred deep links are powerful tools that let you take users directly to specific content in your app, even if the app isn’t installed at the time of the link click. Once the app is installed, the user is redirected to the intended screen—creating a seamless onboarding experience.
In this guide, we’ll walk you through:
Setting up the Install Referrer API
Handling the deep link after app install
Sending install data back to Smler
Routing users to the right screen using the link
When a user clicks a Smler deferred link and installs your app:
The Install Referrer contains the link metadata (like query parameters).
Your app reads this data during first launch.
You can parse it to navigate to the correct screen or content.
You notify Smler via a simple API call to record the install.
Let’s implement this in your app.
In your build.gradle
:
dependencies { implementation 'com.android.installreferrer:installreferrer:2.2' }
Here’s the code to fetch the install referrer inside your app:
package `in`.smler.deferredlink import android.content.Context import android.util.Log import com.android.installreferrer.api.InstallReferrerClient import com.android.installreferrer.api.InstallReferrerStateListener import com.android.installreferrer.api.ReferrerDetails import androidx.core.content.edit import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import java.net.URLEncoder import java.net.HttpURLConnection import java.net.URL class InstallReferrerClientManager(private val context: Context) { fun fetchReferrer() { val prefs = context.getSharedPreferences("smler_preference", Context.MODE_PRIVATE) val isFirstInstall = prefs.getBoolean("is_first_install", true) if (!isFirstInstall) { Log.d("ReferrerClient", "Not first install. Skipping referrer fetch.") return } val referrerClient = InstallReferrerClient.newBuilder(context).build() Log.d("ReferrerClient", "Starting connection...") referrerClient.startConnection(object : InstallReferrerStateListener { override fun onInstallReferrerSetupFinished(responseCode: Int) { when (responseCode) { InstallReferrerClient.InstallReferrerResponse.OK -> { val response: ReferrerDetails = referrerClient.installReferrer val referrerUrl = response.installReferrer Log.d("ReferrerClient", "Referrer URL: $referrerUrl") // Save flag prefs.edit { putBoolean("is_first_install", false) } // Notify Smler notifySmlerInstall(referrerUrl) } InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> Log.w("ReferrerClient", "Install Referrer not supported") InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE -> Log.w("ReferrerClient", "Install Referrer service unavailable") } referrerClient.endConnection() } override fun onInstallReferrerServiceDisconnected() { Log.d("ReferrerClient", "Referrer service disconnected") } }) } private fun notifySmlerInstall(referrer: String) { CoroutineScope(Dispatchers.IO).launch { try { val encoded = URLEncoder.encode(referrer, "UTF-8") val url = URL("https://smler.in/api/v1/deferred-link/install?details=$encoded") val conn = url.openConnection() as HttpURLConnection conn.requestMethod = "GET" val responseCode = conn.responseCode Log.d("ReferrerClient", "Install ping response: $responseCode") conn.disconnect() } catch (e: Exception) { Log.e("ReferrerClient", "Error notifying Smler", e) } } } }
🔁 Call fetchReferrer()
once in your MainActivity
or Application
class.
After app install, if the user is redirected to your app, the intent will contain the deep link.
Add this logic to your activity:
private fun handleIntentDeepLink() { val page = intent?.data?.getQueryParameter("page") val fullUrl = intent?.data.toString() Log.i("MainActivity", "Intent URL: $fullUrl") Log.i("MainActivity", "Page Param: $page") // Navigate to specific screen based on query param when (page) { "123" -> openOfferPage() "home" -> openHome() else -> handleUriFallback(fullUrl) } } override fun onNewIntent(intent: Intent?) { super.onNewIntent(intent) setIntent(intent) handleIntentDeepLink() }
You can configure page=xyz
in the Smler dashboard while creating the deferred link.
Alternatively, use the entire URI path to route users (e.g., /product/9876
→ navigate to product page).
Ensure your AndroidManifest.xml
supports link routing:
<activity android:name=".MainActivity"> <!-- scheme for opening universal links --> <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="smler.in" android:pathPrefix="/your/custom/path" /> </intent-filter> <!-- Custom scheme like smler:// awesomeapp:// --> <intent-filter> <data android:scheme="smler" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter> </activity>
You can match the exact path structure you're using in Smler.
✅ Always test your deep links on fresh installs.
📥 Make sure your app handles null values gracefully if no referrer is received.
🔒 Secure your API usage — avoid leaking sensitive data from the referrer string.
🧪 Use Play Install Referrer Test Tool to simulate referrer behavior.
By integrating Smler’s deferred deep linking with the Google Install Referrer API, you ensure users land on the exact screen they expect — even after installing your app.
It’s simple, lightweight, and requires no third-party SDK. Just configure once, and track installs and navigation effortlessly.
👉 Start creating your deferred links here: