Deep linking

The Adjust SDK enables you to use deep links to direct users to specific pages in your application. You can also gather information about the deep link and its content for later use.

There are two types of deep linking:

  • Direct: Direct deep linking occurs when a user already has your app installed on their device. When this is the case, the deep link will redirect the user to the screen specified in the link.
  • Deferred: Deferred deep linking occurs when a user does not have your app installed on their device. When this is the case, the deep link will first send the user to the device app store to install the app. Once the user has installed and opened the app, the SDK will redirect them to the screen specified in the link.

The deep link URL will be accessible using the SDK after the user opens the app from a tracker URL.

Direct deep linking

If a user already has your app on their device, it will open when they interact with a tracker containing a deep link. You can then parse the deep link information for further use. To do this, you need to choose a desired unique scheme name.

You can set up a specific activity to launch when a user interacts with a deep link. To do this:

  1. Assign the unique scheme name to the activity in your AndroidManifest.xml file.
  2. Add the intent-filter section to the activity definition.
  3. Assign an android:scheme property value with your preferred scheme name.

For example, you could set up an activity called MainActivity to open like this:

<activity
    android:name=".MainActivity"
    android:configChanges="orientation|keyboardHidden"
    android:label="@string/app_name"
    android:screenOrientation="portrait">

    <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="adjustExample" />
    </intent-filter>
</activity>

To open your app when a user clicks on a tracker URL, add its scheme name to the Adjust tracker as a deep_link parameter. A tracker URL without any extra information might look like this: https://app.adjust.com/abc123?deep_link=adjustExample%3A%2F%2F

Important:
The deep_link parameter must be URL encoded.

If you follow the above example, your app will open when a user interacts with a tracker URL. Once it opens, it will launch the MainActivity activity. You will receive information about the deep_link parameter content inside the MainActivity class. The SDK will decode the parameter's content.

You can set the delivery location of the deep_link parameter content. To do this, set the android:launchMode property on your activity. You can find this in your AndroidManifest.xml file. See Android's official documentation for more information about the android:launchMode property.

The SDK will deliver deep link information within the Intent object of your activity. It uses either the activity's onCreate or onNewIntent methods to do this. Once you have launched your app and triggered one of these methods, you can access the deep link content. You can then use this information in other places in your app.

You can extract deep link content from either of these methods like this:

Java

Using the onCreate method:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Intent intent = getIntent();
    Uri data = intent.getData();
    // data.toString() -> This is your deep_link parameter value.
}

Using the onNewIntent method:

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    Uri data = intent.getData();
    // data.toString() -> This is your deep_link parameter value.
}

Deferred deep linking

The Adjust SDK opens deferred deep links by default. No additional setup is required. If you want to disable or change this behavior, you need to set up a deferred deep link callback.

Deferred deep linking callback

You can configure the Adjust SDK to call a delegate function when it receives a deferred deep link. This delegate function receives the deep link as a string argument.

If you want to open the deep link, return true in your delegate function. If you don't want to open it, return false.

Java
Javascript
AdjustConfig config = new AdjustConfig(this, appToken, environment);

// Evaluate the deeplink to be launched.
config.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() {
            @Override
            public boolean launchReceivedDeeplink(Uri deeplink) {
                Log.d("example", "Deferred deep link callback called!");
                Log.d("example", "Deep link URL: " + deeplink);

                return true;
            }
        });

Adjust.onCreate(config);

Example

Reattribution using deep links

Adjust enables you to run re-engagement campaigns with usage of deep links. For more information, see our guide to appending attribution data to a deep link.

To reattribute your user, you need to make an extra call to the Adjust SDK within your app. Add a call to the appWillOpenUrl(Uri, Context) method when the app receives deep link content. The Adjust SDK will then look for new attribution data within the deep link. If the SDK finds new information, it will forward it to the Adjust backend for reattribution.

Java
Javascript

Using the onCreate method:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Intent intent = getIntent();
    Uri data = intent.getData();
    Adjust.appWillOpenUrl(data, getApplicationContext());
}

Using the onNewIntent method:

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    Uri data = intent.getData();
    Adjust.appWillOpenUrl(data, getApplicationContext());
}

Link resolution

Some Email Service Providers (ESP) use their own custom tracking domains for marketing campaigns. If you need to track clicks through a custom domain, you will need to set the SDK up to resolve the link. To do this, call the resolveLink method of the AdjustLinkResolution class. The Adjust SDK will then follow the custom link and resolve it when opening the deep link. This ensures that you record the interaction with your email tracking campaign.

The resolveLinkWithUrl method takes the following parameters:

  • url - the deep link that opened the application.
  • resolveUrlSuffixArray - the custom domains of the configured campaigns that need to be resolved.
  • adjustLinkResolutionCallback - the callback that will contain the final URL.

The method will check the deep link against the domains in the resolveUrlSuffixArray. If it does not find any matches, it will forward the deep link URL as is. If it does find a match, it will attempt to resolve the link and return the resulting deep link. It will then store this in the callback parameter. You can then use the returned deep link to reattribute your user. To do this, pass the deep link to the Adjust.appWillOpenUrl method.

Note:
The Adjust SDK will follow up to ten redirects when attempting to resolve a URL. It will return the latest URL it has followed as the callback URL. If there are more than ten redirects, the SDK will return the tenth redirect URL.
Java
AdjustLinkResolution.resolveLink(url, 
                                 new String[]{"example.com"},
                                 new AdjustLinkResolution.AdjustLinkResolutionCallback() {
    @Override
    public void resolvedLinkCallback(Uri resolvedLink) {
        Adjust.appWillOpenUrl(resolvedLink, getApplicationContext());
    }
});