The OneLink Developer Hub

Welcome to the OneLink developer hub. You'll find comprehensive guides and documentation to help you start working with OneLink as quickly as possible, as well as support if you get stuck. Let's jump right in!

Deferred deep linking

At a glance: Deferred deep linking setup enables the marketer to create links that will send new app users first to the correct app store to install the app, and then, after the first open, to a specific app experience (e.g. a specific page in the app).

Overview

Deferred deep linking directs new users first to the correct app store to install the app, and then, after the first open, to a specific app experience (e.g. a specific page in the app).

When the user first launches the app, the onConversionDataSuccess callback function receives both the conversion data of the new user, and OneLink data. The OneLink data makes in-app routing possible due to the additional parameters that are passed to the app when the OS opens the app. AppsFlyer's OneLink ensures that the correct parameters are passed along with the user's click, thus personalizing the user’s app experience.

The marketer and developer must coordinate regarding desired app behavior and parameter names. The marketer will use the parameters to create the deferred deep links.

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 on a device on which the app is not installed.
  2. AppsFlyer registers the click and redirects the user to the correct app store or landing page.
  3. The user installs the application and launches it.
  4. iOS verifies the Universal Link ownership using the Apple App Site Association file hosted by AppsFlyer in the location: https://myapp.onelink.me/.well-known/apple-app-site-association
  5. AppsFlyer SDK is initialized and the install is attributed in AppsFlyers's servers.
  6. The SDK triggers the onConversionDataSuccess method. The function receives input that includes both attribution data and the parameters defined in the OneLink data.
  7. The parameter is_first_launch has the value true, that signals the deferred deep link flow.
    The developer uses the data received in the onConversionDataSuccess function to create a personalized experience for the user for the application’s first launch.

Procedures

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

Procedure checklist

  1. Deciding app behavior on first launch, and parameter names and values (with marketer)
  1. Planning method input, i.e. parameter names and values (with marketer)
  1. Implementing the onConversionDataSuccess() logic
  1. Implementing the onConversionDataFail() logic

Deciding app behavior on first launch

To decide app behavior on first launch:

Get from the marketer: The expected behavior of the link when it is clicked and the app opens for the first time.

Planning method input

For deferred deep linking, the onConversionDataSuccess method input must be planned and the input decided in the previous section (for deep linking) is made relevant for the first time the app is launched.

The onConversionDataSuccess method gets variables as an input like this:

data: [AnyHashable: Any]

View the list of variables (parameters).

The map holds two kinds of data:

  • Attribution data
  • Data defined by the marketer in the link (parameters and values)
    Parameters can be either:
    • AppsFlyer official parameters.
    • Custom parameters and values chosen by the marketer and developer.

The input data structure is described here.

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

To plan 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 parameters and values.
    Note: Conversion data will not return a custom parameter named "name, " with a lowercase "n".

Implementing onConversionDataSuccess() logic

When the app is opened for the first time, the onConversionDataSuccess method is triggered in the main activity. The parameters in the method input are used to implement the specific user experience when the app is first launched.

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

// Handle Organic/Non-organic installation
func onConversionDataSuccess(_ data: [AnyHashable: Any]) {

    print("onConversionDataSuccess data:")
    for (key, value) in data {
        print(key, ":", value)
    }

    if let status = data["af_status"] as? String {
        if (status == "Non-organic") {
            if let sourceID = data["media_source"],
                let campaign = data["campaign"] {
                print("This is a Non-Organic install. Media source: \(sourceID)  Campaign: \(campaign)")
            }
        } else {
            print("This is an organic install.")
        }
        if let is_first_launch = data["is_first_launch"] as? Bool,
            is_first_launch {
            print("First Launch")
            if let fruit_name = data["fruit_name"]
            {
                // The key 'fruit_name' exists only in OneLink originated installs
                print("deferred deep-linking to \(fruit_name)")
                walkToSceneWithParams(params: data)
            }
            else {
                print("Install from a non-owned media")
            }
        } else {
            print("Not First Launch")
        }
    }
}

⇲ Github links: Swift

Implementing onConversionDataFailure() logic

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

To implement the onConversionDataFailure method:

Enter the following code:

func onConversionDataFail(_ error: Error) {
    print("\(error)")
}

⇲ Github links: Swift

Updated about 13 hours ago


Deferred deep linking


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.