Skip to main content

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 launches ProductActivity.
  • 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, and ProductActivity 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.

AndroidManifest.xml
<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>

In MainActivity, capture the deep link intent and forward it to MainApplication.

MainActivity.java
Intent intent = getIntent();
Uri data = intent.getData();
// data.toString() -> This is your deep_link parameter value.
if (!(data == null)){
TrackierSDK.parseDeepLink(data);
}

3. Initialize SDK in Application Class

Set up the AppTrove SDK and define a method to process deep links forwarded from MainActivity.

MainApplication.java
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);
}
}

Call TrackierSDK.resolveDeeplinkUrl in your activity to resolve the dynamic link and print the resulting URL to the log.

MainApplication.java
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);
});
}
}

Testing

In a browser or messaging app, click: https://trackier58.u9ilnk.me/d/PGJ2m4NtP

Steps to Test Deferred Deep Linking

Follow these comprehensive steps to properly test deferred deep linking functionality:

Prerequisites
  • 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
Expected Behavior

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
Important Notes
  • 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

IssueSolution
No Play Store redirectCheck Store Redirect in Trackier Panel.
Deep link not forwardedEnsure MainActivity calls handleDeepLink.
Wrong activityVerify dlv=standard matches MainApplication logic.
Missing parametersConfirm URL includes productid and quantity.
No events loggedValidate SDK key and network.