Skip to main content

Defer SDK Start

Deferring the AppTrove SDK start allows you to control when the SDK initializes and fires the install event, enabling precise tracking on a specific page or after user actions (e.g., consent or onboarding). With manual mode enabled, the SDK won't initialize automatically on app launch, giving you flexibility to trigger it when desired.

Overview

Deferring SDK start is ideal for:

  • Custom Install Timing: Fire the install event on a specific activity (e.g., after user onboarding).
  • Privacy Compliance: Delay tracking until user consent is obtained.
  • Campaign Accuracy: Ensure installs are attributed only when users reach a key page.
  • Use Case: Initialize the SDK and fire an install event when users reach MainActivity after clicking a deep link like https://trackier58.u9ilnk.me/d/PGJ2m4NtPd.

Key Steps

  1. Configure the SDK with setManualMode(true) to defer initialization.
  2. Initialize the SDK and fire the install event explicitly in the desired activity.

Implementation

Application Class Setup

import android.app.Application;
import com.trackier.sdk.TrackierSDK;
import com.trackier.sdk.TrackierSDKConfig;
import java.util.HashMap;

public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
final String TR_SDK_KEY = "XXXXXXX-XXXX-XXXX-80e3-5938fadff"; // Please pass your SDK key here.

/* While Initializing the SDK, You need to pass the three parameter in the TrackierSDKConfig.
* In First argument, you need to pass context of the application
* In second argument, you need to pass the AppTrove SDK api key
* In third argument, you need to pass the environment which can be either "development", "production" or "testing". */
TrackierSDKConfig sdkConfig = new TrackierSDKConfig(this, TR_SDK_KEY, "development");

// Enable manual mode to defer SDK initialization
sdkConfig.setManualMode(true);

// Set local reference tracking (optional)
TrackierSDK.setLocalRefTrack(true, "_");

// Initialize SDK with configuration
TrackierSDK.initialize(sdkConfig);
}
}

Important Notes

  • Set manual mode to true by passing true boolean value to setManualMode().
  • The second method is to associate user email.
  • Note: Make sure to take EXTERNAL_STORAGE_READ permission before enabling this feature. For reference, you can see the example directory.

Firing the Install Event

You can explicitly fire Install whenever desired:

TrackierSDK.fireInstall();