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
- Uninstall the app.
- Click the tracker URL.
- Verify redirection to the Play Store.
- Install and open the app.
- Confirm:
MainActivity
launches and forwards the deep link.ProductActivity
opens with "Product: jeans, Quantity: 3".
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. |