Skip to content

DeepLink

Istvan Farkas edited this page Jul 16, 2019 · 5 revisions

Contents

What is deep linking?

In the context of mobile apps, deep linking is a term which describes the flow when a user tap on a link opens the mobile application instead of the page in a browser.

Requirements

  1. Enable HTTPS on existing link domains by adding certificates

    The first task here is to enable HTTPS on your existing link domains. You should also add certificates to them.

  2. Serve JSON files on the link domain

    Now, you should provide JSON configuration files to these link domains, which create the direct relationship with the apps. These files are checked at app install. For more information, check here for iOS and here for Android.

  3. Enable link domains in the app

    • for iOS, the com.apple.developer-associated-domains should be added as an appLink. The app will receive the URL as an activity. For more information, read the iOS documentation for Support of Universal Links
    • for Android, an intent should be added with the link domain. For more information, see the Android documentation for creating Intent Handlers
  4. The well set application installed on the device already

What does deep link tracking mean in Emarsys?

When Emarsys provides a link which is trackable (usually in emails), and the user clicks on it, the click can be reported to Emarsys by the SDK.

Note

Deep linking or deep link tracking doesn't mean that any screen/content will be automatically opened in the application. If it's a case for you, you should do it manually.

Requirements

  1. All of the points above are set correctly

  2. Add deep links as trackable links in email

    The next step is using the UniversalLinks in iOS and the URL schemes in Android as trackable links in emails.

  3. Process links in the app

    • for iOS in order to track deep links with the Emarsys SDK, you need to call trackDeepLink in your AppDelegate's application:continueUserActivity:restorationHandler: method.

      Objective-C

       -  (BOOL)application:(UIApplication *)application
       continueUserActivity:(NSUserActivity *)userActivity
         restorationHandler:(void (^)(NSArray *__nullable restorableObjects))restorationHandler {
           return [Emarsys trackDeepLinkWith:userActivity sourceHandler:^(NSString *source) {
               NSLog([NSString stringWithFormat:@"Source url: %@", source]);
           }];
       }

      Swift

      func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
          return Emarsys.trackDeepLink(with: userActivity, sourceHandler: { url in
              if let source = url {
                  print(source)
              }
          })
      }

      The (BOOL) return value of Emarsys.trackDeepLink indicates whether the UserActivity contained a Mobile Engage email deeplink and whether it was handled by the SDK.

      The first parameter is the UserActivity that comes from the AppDelegate’s application:continueUserActivity:restorationHandler: method.

      The second parameter is optional, it is a closure/block that provides the source Url that was extracted from the UserActivity.

      For more information, read the relevant iOS documentation.

    • for Android, Emasrys SDK automatically handles deep link tracking with most use cases, with only one exception: manual tracking is needed when your Activity has onNewIntent overriden. In that case, you can track the deep link using the trackDeepLink method like below:

      Java

      @Override
      protected void onNewIntent(Intent intent) {
          super.onNewIntent(intent);
          Emarsys.trackDeepLink(this, intent, new CompletionListener(){
      
          	 @Override
               public void onCompleted(@Nullable Throwable errorCause) {
               ...
               }
          );
      }

      Kotlin

      override fun onNewIntent(intent:Intent) {
          super.onNewIntent(intent)
          Emarsys.trackDeepLink(this, intent) {throwable -> ...}
      }

What is NOT deep linking?

In the context of mobile apps, there is a common mistake to use the deep link term for every event/trigger that somehow connects with the application.

push to app event

Using the Emarsys SDK's rich notification feature the customer can send notification which contains application event as (default)action when user triggers it the registered push event handler will be called with the given name and payload parameters.

push to external url event

Using the Emarsys SDK's rich notification feature the customer can send notification which contains an url as (default)action when user triggers it the url will be opened outside of the application.

inApp to app event

Using the Emarsys SDK's in app messaging feature the customer can set action in the inApp message which contains a name a payload and when being triggered by the user the registered inApp event handler will be called by the SDK with the given name and payload parameters.

inApp to external url event

Using the Emarsys SDK's in app messaging feature the customer can set action in the inApp message which contains an url and when being triggered by the user the url will be opened outside of the application.

custom data fields

On the Mobile Engage / Push page there is an option to set custom data fields which are traveling in the push payload and which are extractable when the push message arrives into the application.