Direct deep linking

At a glance: Direct deep linking setup enables the marketer to create links that will send existing app users to a specific app experience (e.g. a specific page in the app). Deep link setup is also a prerequisite for deferred deep linking.


Deep linking directs mobile users into a specific activity or content in an app.

This in-app routing to a specific activity in the app is possible due to the deep_link_value that is passed to the app when the OS opens the app and the onAppOpenAttribution method is called. AppsFlyer's OneLink ensures that the correct value is passed along with the user's click, thus personalizing the user’s app experience.

Only the deep_link_value is required for deep linking. However, other parameters and values (such as custom attribution parameters) can also be added to the link and returned by the SDK as deep linking data.

The marketer and developer must coordinate regarding desired app behavior and deep_link_value. The marketer uses the parameters to create deep links, and the developer customizes the behavior of the app based on the value received.

The AppsFlyer SDK returns the parameters from the link that the user clicked, and it is the developer's responsibility to make sure the parameters are handled correctly in the app, for both in-app routing, and personalizing data in the link.

The deep linking flow works as follows:

  1. User clicks the OneLink short URL.
  2. Android launches the app based on the relevant activity in the AndroidManifest.xml.
  3. AppsFlyer SDK is triggered in the app.
  4. AppsFlyer SDK retrieves the OneLink data.
    • In a short URL, the data is retrieved from the short URL resolver API in AppsFlyer's servers.
    • In a long URL, the data is retrieved directly from the long URL.
  5. AppsFlyer SDK triggers onAppOpenAttribution() with the retrieved parameters and cached attribution parameters (e.g. install_time).
  6. Asynchronously, onConversionDataSuccess() is called, holding the full cached attribution data. (You can exit this function by checking if is_first_launch is true.)
  7. onAppOpenAttribution() uses the attributionData map to dispatch other activities in the app and pass relevant data.
    • This creates the personalized experience for the user, which is the main goal of OneLink.


To implement the onAppOpenAttribution method and set up the parameter behaviors, the following action checklist of procedures need to be completed.

Procedure checklist

  1. Deciding app behavior and deep_link_value (and other parameter names and values) - with the marketer
  1. Planning method input, i.e. deep_link_value (and other parameter names and values) - with the marketer
  1. Implementing the onAppOpenAttribution() logic
  1. Implementing the onAttributionFailure() logic

Deciding app behavior

To decide what the app behavior is when the link is clicked:

Get from the marketer: The expected behavior of the link when it is clicked.

Planning method input

When a OneLink is clicked and the user has the app installed on their device, the onAppOpenAttribution method is called by the AppsFlyer SDK. This is referred to as a retargeting re-engagement.

The onAppOpenAttribution method gets variables as an input like this: Map <String, String>.
The input data structure is described here.

The marketer and developers need to plan the deep_link_value (and possible other parameters and values) together based on the desired app behavior when the link is clicked.

To plan the deep_link_value, and other parameter names and values based on the expected link behavior:

  1. Tell the marketer what parameters and values are needed in order to implement the desired app behavior.
  2. Decide on naming conventions for the deep_link_value and other parameters and values.
    Note: Custom parameters will not appear in raw data collected in AppsFlyer.



The marketer and developers need to decide together on the best long term system for the deep_link_value (and any other parameters/values) to minimize additional app updates.

The deep_link_value can be based on a SKU, post ID, path, or anything else. We strongly recommend agreeing with your developers on a system that allows for you to enter dynamic values on your chosen parameter, so you can generate many different deep links that go to different content within the app, without any further changes to the app code by the developers.

See the following URL examples. The deep_link_value of a fruit type was chosen by the marketer and developer together. And the developers made the values dynamic, so the marketer could enter any fruit without the need for further work by the dev team.**&deep_link_value=apples**...**&deep_link_value=bananas**...**&deep_link_value=peaches**...

Implementing onAppOpenAttribution() logic

The deep link opens the onAppOpenAttribution method in the main activity. The deep_link_value and other parameters in the method input are used to implement the specific user experience when the application is opened.

To implement the logic:

  1. Implement the logic based on the chosen parameters and values. See the following code example.
  2. Once completed, send confirmation to the marketer that the app behaves accordingly.


Sample code

  public void onAppOpenAttribution(Map<String, String> attributionData) {
  if (!attributionData.containsKey("is_first_launch"))
    Log.d(LOG_TAG, "onAppOpenAttribution: This is NOT deferred deep linking");
  for (String attrName : attributionData.keySet()) {
    String deepLinkAttrStr = attrName + " = " + attributionData.get(attrName);
    Log.d(LOG_TAG, "Deeplink attribute: " + deepLinkAttrStr);
  Log.d(LOG_TAG, "onAppOpenAttribution: Deep linking into " + attributionData.get("deep_link_value"));
  goToFruit(attributionData.get("deep_link_value"), attributionData);

  public void onAttributionFailure(String errorMessage) {
  Log.d(LOG_TAG, "error onAttributionFailure : " + errorMessage);

private void goToFruit(String fruitName, Map<String, String> dlData) {
    String fruitClassName = fruitName.concat("Activity");
    try {
        Class fruitClass = Class.forName(this.getPackageName().concat(".").concat(fruitClassName));
        Log.d(LOG_TAG, "Looking for class " + fruitClass);
        Intent intent = new Intent(getApplicationContext(), fruitClass);
        if (dlData != null) {
            // Map is casted HashMap since it is easier to pass serializable data to an intent
            HashMap<String, String> copy = new HashMap<String, String>(dlData);
            intent.putExtra(DL_ATTRS, copy);
    } catch (ClassNotFoundException e) {
        Log.d(LOG_TAG, "Deep linking failed looking for " + fruitName);

⇲ Github links: Java



onAppOpenAttribution is not called when the app is running in the background and Application LaunchMode is not standard.

To correct this, call setIntent(intent) method to set the intent value inside the overridden method onNewIntent if the application is using a non-standard LaunchMode.

import android.content.Intent;
protected void onNewIntent(Intent intent) 

Implementing onAttributionFailure() logic

The onAttributionFailure method is called whenever the call to onAppOpenAttribution fails. The function should report the error and create an expected experience for the user.

To implement the onAttributionFailure method:

Enter the following code:

public void onAttributionFailure(String errorMessage) {
    Log.d(LOG_TAG, "error onAttributionFailure : " + errorMessage);

⇲ Github links: Java

Did this page help you?