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 link URL.
Direct deep linking
If a user already has your app on their device, it will open when they interact with a link 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:
- Assign the unique scheme name to the activity in your
AndroidManifest.xml
file. - Add the
intent-filter
section to the activity definition. - 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 link URL, add its scheme name to the Adjust link as a deep_link
parameter. A link URL without any extra information might look like this: https://app.adjust.com/abc123?deep_link=adjustExample%3A%2F%2F
If you follow the above example, your app will open when a user interacts with a link 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:
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
.
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.
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.
callback
URL. If there are more than ten redirects, the SDK will return the tenth redirect URL.