adjust-icon

Set up deep linking

You can create deep links to take users to specific pages in your app. The Adjust SDK uses different logic depending on if the user already has your app installed on their device:

  • Direct deep linking: occurs if the user already has your app installed. The link takes the user to the page specified in the link
  • Deferred deep linking: occurs if the user doesn’t have your app installed. The link takes the user to a storefront to install your app first. After the user installs the app, it opens to the page specified in the link.

The SDK can read deep link data after a user opens your app from a link.

Configure your scheme name

If a user has your app installed, it opens when they interact with a link containing deep link information. The Adjust SDK contains tools to parse deep link information for use throughout your app. To set up deep linking, you need to choose a unique scheme name.

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

  1. Assign your scheme name to an activity in your AndroidManifest.xml file.
  2. Add an intent-filter node to the activity definition.
  3. Add an android:scheme data node containing your scheme name inside the intent-filter node.

Example

This example shows how to set up an activity called MainActivity to open with the scheme name adjustExample.

AndroidManifest.xml
<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>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="insights.go.link" />
<data android:scheme="https" android:host="insights.go.link" />
</intent-filter>
</activity>

Your app will now be able to handle URI schemes. When a user clicks a link with a deep_link parameter containing your scheme name, this activity fires.

https://app.adjust.com/abc123?deep_link=adjustExample%3A%2F%2F

Ensure that you configure your scheme name even if you’re setting up Android App Links for deep linking.

For Android App Links, add an intent filter to your AndroidManifest.xml file to specify which URLs your app can handle. Include the data element with the android:autoVerify="true" attribute in the intent filter.

<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="insights.go.link" />
<data android:scheme="https" android:host="insights.go.link" />
</intent-filter>

Your app will now be able to handle Android App Links. When a user clicks on a link containing the insights.go.link domain, your app opens automatically.

https://insights.go.link/login?adj_t=abc123

You can specify the delivery location of the deep_link parameter content. To do this, set the android:launchMode property on your activity in your AndroidManifest.xml file.

The Adjust SDK delivers deep link information within your activity’s intent object using either the onCreate or onNewIntent method. You can access deep link content once the app is launched and one of these methods has fired. You can then access this information in other parts of your app.

Extract deep link information by calling the getData() method within the onCreate or onNewIntent method.

Deferred deep linking

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

Method signature
public void setOnDeeplinkResponseListener(OnDeeplinkResponseListener onDeeplinkResponseListener)

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.

Example

This example shows how to prevent the SDK from launching an activity by returning a false value in your callback function.

Method signature
public static void appWillOpenUrl(Uri url, Context context)

Adjust enables you to run re-engagement campaigns with usage of deep links. For more information, check out how to set up Deep links in Campaign Lab.

To reattribute your user, you need to call the appWillOpenUrl method when the app receives deep link content. The Adjust SDK then looks for new attribution data within the deep link. If the SDK finds new information, it forwards the information to Adjust’s servers for reattribution.

Method signature
public static void resolveLink(final String url,
final String[] resolveUrlSuffixArray,
final AdjustLinkResolutionCallback adjustLinkResolutionCallback)

Some Email Service Providers (ESPs) use their own custom domains for marketing campaigns. If you need to measure clicks through a custom domain, you 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 measurement campaign.

The resolveLinkWithUrl method takes the following arguments:

  • url (String): the deep link that opened the application.
  • resolveUrlSuffixArray (String[]): the custom domains of the configured campaigns that need to be resolved.
  • adjustLinkResolutionCallback (AdjustLinkResolutionCallback): the callback that returns the final URL.

The method checks the deep link against the domains in the resolveUrlSuffixArray. If it doesn’t find any matches, it forwards the deep link URL as is. If it does find a match, it attempts to resolve the link and return the resulting deep link. It then stores this in the callback parameter.

You can use the returned deep link to reattribute your user. To do this, pass the deep link to the Adjust.appWillOpenUrl method.