Deferred Deep Linking
Deferred deep linking happens when a user does not have your app installed on their device. When the user clicks a Trackier URL, the URL will redirect them to the Play Store to download and install your app. When the user opens the app for the first time, the SDK will read the deep_link
content.
The AppTrove SDK opens the deferred deep link by default. You just need to add some code in the application class right after initializing the AppTrove SDK.
Deferred deep linking directs users to specific in-app content after installing the app via a Trackier URL, or instantly if the app is already installed. This guide implements a flow where MainActivity
receives the simple deep link (e.g., https://trackier58.u9ilnk.me/d/PGJ2m4NtPd
), passes it to the Application class for processing, and navigates to ProductActivity
to display parameters (e.g., productid
, quantity
).
Overview
Deferred deep linking ensures users reach intended content seamlessly:
- Normal Deep Link: When the app is installed,
MainActivity
captures the URL (e.g.,https://trackier58.u9ilnk.me/d/PGJ2m4NtPd
) and sends it to the Application class, which launchesProductActivity
. - Deferred Deep Link: When the app is not installed, Trackier redirects to the Play Store. After installation,
MainActivity
receives the deep link data, forwards it to the Application class, andProductActivity
displays the content. - Use Case: Show "Product: jeans, Quantity: 3" after clicking a link like
https://trackier58.u9ilnk.me/d/PGJ2m4NtPd?dlv=standard&productid=jeans&quantity=3
.
Example URLs:
- Short:
https://trackier58.u9ilnk.me/d/PGJ2m4NtPd
- Long:
https://trackier58.u9ilnk.me/d/PGJ2m4NtPd?pid=QR_Code&cost_value=100343&cost_currency=USD&lbw=1h&camp=VistMarketCampaign&dlv=standard&p1=reewrwrwerwe&p2=New+Product&productid=jeans&quantity=3&id=3234234
Prerequisites
- AppTrove SDK:
com.trackier:android-sdk:1.6.68
or later. - Android: API 19+ (Android 4.4).
- Trackier Panel: Configured through Panel with deep link settings.
- Play Store: App available for testing.
- Dependencies: Internet permission.
Implementation
This implementation routes the deep link from MainActivity
to the Application class, which then launches ProductActivity
.
1. Configure AndroidManifest.xml
Add an intent filter to MainActivity
to capture deep links.
<application
android:name=".MainApplication"
...>
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<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="trackier58.u9ilnk.me"
android:pathPrefix="/d/" />
</intent-filter>
</activity>
<activity
android:name=".ProductActivity"
android:exported="true" />
</application>
2. Capture Deep Link Data in MainActivity
In MainActivity
, capture the deep link intent and forward it to MainApplication
.
- Java
- Kotlin
Intent intent = getIntent();
Uri data = intent.getData();
// data.toString() -> This is your deep_link parameter value.
if (!(data == null)){
TrackierSDK.parseDeepLink(data);
}
// Retrieve deep link data
val deepLinkUri: Uri? = intent?.data
deepLinkUri?.let {
Log.d("DeepLinkHandler", "Received Deep Link URI: $it")
TrackierSDK.parseDeepLink(it)
}
3. Initialize SDK in Application Class
Set up the AppTrove SDK and define a method to process deep links forwarded from MainActivity
.
- Java
- Kotlin
import android.app.Application;
import android.content.Intent;
import androidx.annotation.NonNull;
import com.trackier.sdk.DeepLink;
import com.trackier.sdk.DeepLinkListener;
import com.trackier.sdk.TrackierSDK;
import com.trackier.sdk.TrackierSDKConfig;
public class MainApplication extends Application {
DeepLinkListener deepLinkListener = new DeepLinkListener() {
@Override
public void onDeepLinking(@NonNull DeepLink deepLink) {
if (deepLink.getDeepLinkValue().equalsIgnoreCase("ProductActivity")) {
Intent intent = new Intent(MainApplication.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
};
@Override
public void onCreate() {
super.onCreate();
final String TR_DEV_KEY = "XXXXXXX-XXXX-XXXX-80e3-5938fadff"; // Replace with your SDK key
TrackierSDKConfig sdkConfig = new TrackierSDKConfig(this, TR_DEV_KEY, "development");
sdkConfig.setDeepLinkListener(deepLinkListener);
sdkConfig.disableOrganicTracking(true);
TrackierSDK.initialize(sdkConfig);
}
}
package com.example.myapp
import android.app.Application
import android.content.Intent
import android.util.Log
import com.trackier.sdk.DeepLink
import com.trackier.sdk.DeepLinkListener
import com.trackier.sdk.TrackierSDK
import com.trackier.sdk.TrackierSDKConfig
class MainApplication : Application() {
private val deepLinkListener = object : DeepLinkListener {
override fun onDeepLinking(deepLink: DeepLink) {
// Log deep link details for debugging
Log.d("TrackierSDK", "Deep Link Value: ${deepLink.getDeepLinkValue()}")
Log.d("TrackierSDK", "Deep Link URL: ${deepLink.getUrl()}")
Log.d("TrackierSDK", "Deep Link Data: ${deepLink.getData()}")
// Check deep link value
if (deepLink.getDeepLinkValue().equals("standard", ignoreCase = true)) {
// Prepare intent for ProductActivity
val intent = Intent(this@MainApplication, ProductActivity::class.java).apply {
putExtra("productid", deepLink.getQueryParam("productid"))
putExtra("quantity", deepLink.getQueryParam("quantity"))
flags = Intent.FLAG_ACTIVITY_NEW_TASK // Required outside Activity
}
startActivity(intent)
} else {
Log.d("TrackierSDK", "Invalid or missing deep link value")
}
}
}
override fun onCreate() {
super.onCreate()
// Initialize AppTrove SDK
val sdkKey = "YOUR_SDK_KEY" // Replace with your SDK key
val sdkConfig = TrackierSDKConfig(this, sdkKey, "development").apply {
setDeepLinkListener(deepLinkListener)
// Optional: Disable organic tracking
disableOrganicTracking(true)
}
TrackierSDK.initialize(sdkConfig)
Log.d("TrackierSDK", "SDK Initialized with DeepLinkListener")
}
}
4. Call resolveDeeplinkUrl
to Get Deferred Deep Link
Call TrackierSDK.resolveDeeplinkUrl
in your activity to resolve the dynamic link and print the resulting URL to the log.
- Java
- Kotlin
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import com.trackier.sdk.TrackierSDK;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Resolve and print the deferred deep link URL
TrackierSDK.resolveDeeplinkUrl("https://trackier58.u9ilnk.me/d/NKmWH9E7b1", resultUrl -> {
Log.d("TrackierSDK", "Resolved Deferred Deep Link URL: " + resultUrl);
});
}
}
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.trackier.sdk.TrackierSDK
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Resolve and print the deferred deep link URL
TrackierSDK.resolveDeeplinkUrl("https://trackier58.u9ilnk.me/d/NKmWH9E7b1") { resultUrl ->
Log.d("TrackierSDK", "Resolved Deferred Deep Link URL: $resultUrl")
}
}
}
Testing
Test Deep Link
In a browser or messaging app, click: https://trackier58.u9ilnk.me/d/PGJ2m4NtP
Test Deferred Deep Link
Steps to Test Deferred Deep Linking
Follow these comprehensive steps to properly test deferred deep linking functionality:
- APK File: Ensure you have the APK file integrated with the AppTrove SDK
- Test Device: Android device with File Manager or WhatsApp access
- Test URL: Valid deferred deep link URL with all required parameters
Step-by-Step Testing Process
1. Prepare the APK
- Store the APK file locally on your device
- Keep it accessible in File Manager or WhatsApp (as a file message)
- Ensure the APK contains the latest SDK integration
2. Trigger the Deferred Link Click on the test deep link containing all required parameters:
https://yourdomain.u9ilnk.me/d/Af2xeLPI77?pid=Ron+Media+Source&cost_value=0&cost_currency=GBP&lbw=1d&camp=Ron+Referral+Test&dlv=RonTestClass&p2=param_2_value&sdk_param=sdk_param_value
The link should redirect you to the Google Play Store page of your app.
3. Install from Local APK (Instead of Play Store)
- Once redirected to the Play Store, minimize it (don't install from there)
- Open the File Manager (or WhatsApp) where the prepared APK is stored
- This simulates the deferred deep link scenario without using the actual Play Store
4. Install the APK Manually
- Tap on the APK file and install it on the device
- Grant necessary permissions during installation
- Complete the installation process
5. Launch the App
- Open the freshly installed app
- The SDK should automatically process the deferred deep link
- Verify that the deep link parameters are correctly received and processed
Verification Checklist
Deep Link Processing
- App launches successfully after installation
- Deep link data is received by the SDK
DeepLinkListener.onDeepLinking()
is triggered- Deep link parameters are correctly parsed
Parameter Validation
- All URL parameters are accessible via
deepLink.getQueryParam()
- Custom parameters (p1, p2, etc.) are correctly extracted
- SDK parameters are properly processed
Navigation Flow
- Correct activity/screen is launched based on
dlv
parameter - User is directed to the intended content
- Deep link data is passed to the target activity
- Always test with fresh app installations to simulate real user scenarios
- Verify that the SDK is properly initialized before processing deep links
- Test on both development and production environments
- Ensure network connectivity during testing
Common Issues
Issue | Solution |
---|---|
No Play Store redirect | Check Store Redirect in Trackier Panel. |
Deep link not forwarded | Ensure MainActivity calls handleDeepLink . |
Wrong activity | Verify dlv=standard matches MainApplication logic. |
Missing parameters | Confirm URL includes productid and quantity . |
No events logged | Validate SDK key and network. |