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

  1. Uninstall the app.
  2. Click the tracker URL.
  3. Verify redirection to the Play Store.
  4. Install and open the app.
  5. Confirm:
    • MainActivity launches and forwards the deep link.
    • ProductActivity opens with "Product: jeans, Quantity: 3".

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.