How To Implement Deep Linking on iOS

Advanced Linking with Tapstream

We have covered Tapstream’s suite of solutions in a previous article, but, in a nutshell, Tapstream offers a complete range of products to measure customer acquisitions through sophisticated attribution tools and on-boardling links.

Tapstream’s Onboarding Links tool is a more sophisticated take on deep linking. Tapstream’s Deferred Deep Links “allow you to send users who already have your app directly inside your app to a deep destination when they click the Tapstream campaign link. If the user doesn’t have your app, Tapstream will redirect them to a fallback destination you define for their platform,” according to the company. “When they install your app, you can use the Tapstream SDK’s Onboarding Links feature to find out what their intended deep link destination was.”

image

This sounds similar to App Link’s offering, but with additional features that we will shortly discover.

The concept of Deferred aspect means that even if the referred app requires a prior login or registration to continue, the deep linking is deferred until after that, and then directs the user to the final intended destination. This is one up from the fallback process of directing to the App Store if the user hasn’t got an actively installed copy of the destination app.

Getting started with Tapstream Campaigns and Deep Linking

Tracking URLs or short links provide analytical information on the interaction with the links from users (such as number of clicks or conversions), whereby visitors interacting with campaign links are redirected to a predetermed destination, which is in fact a deep link.

When you work with campaigns, each campaign has a unique campaign URL link, which allows you to track how each ad campaign is faring. With Tapstream, there are four types of campaigns:

Each of the campaigns above offers a unique ways of tracking and anlysing user behavior and movements, but one common theme is the campaign name and campaign URL, which you set. What sets Tapstream apart from other solutions of its kind is that is allows organizatons to bake Deferred Deep Links into campaigns.

Implementing Deferred Deep Links

As mentioned, all campaigns support deferred deep links, which send your users to a deep link within your app when they click a Tapstream campaign link, with the fallback option of redirection to a predefined destination, such as the App Store.

To get started with Tapstream you have to create a registered URL scheme. Additionally, you implement the latest Tapstream SDK, which we will detail later in the article.

Within each campaign, there is an Advanced button by the specified App URL you have provided in the campaign settings, allowing you to create a new destination for each platform that you will support (i.e., iOS, Android), setting the following properties:

  • Destination name (such as iPhone Deep Link)

  • Deep Link destination URL (matching the iOS registered URL option set earlier)

  • Fallback destination url

    Once you have set up the New Destination under Advanced for the campaign, all URLs will automatically start using the deferred deep links, as well as utilizing the Tapstream Onboarding links capabilities, which are essentially fancy "landing pages" designed to encourage users to click the deep link.

 

Advanced Link Redirection & Split Testing

Tapstream allows campaign links to redirect users based on device type, which allows marketing processes such as split testing to be performed. This ia part of the Advanced campaign, but rather than just having a static destination URL, such as /marketing/, you have something like /marketing/food=cat, which would then show up in performance reports, segmented by specific and customized parameter variables.

If you do opt to have more than one destination per device, Tapstream automatically performs split tests between destinations, weighted by the weight field. This would allow you to define more than one landing page (onboarding) and see which ad campaign does better, based on random selection.

Dynamic Redirection

Dynamic Redirection is a relatively recent addition to Tapstream. Dynamic Redirection is the ability to have destination URL definitions append macros that resolve to the values of keys on the inbound link’s query string This is useful for parsing and translating paramers such as profile IDs, product listings and device-specific destinations via URL-encoded values. The macros would be invoked as follows:

Suppose you have a campaign link, /products whereby the destination URL would be {{ url: “https://amazon.com/products}}/{{ productId:”242122244"}}

We would re-direct the destination URL as follows:

/products –> https://amazon.com/products/242122244 /products?url=http%3A%2F%2Ftapstream.com –> https://tapstream.com/242122244

This allows for not only greater reporting capabilities, but also the ability to append runtime destination URLs redirections.

Installing the Tapstream SDK

The Tapstream SDK can be installed by using cocoapods and adding to the Podfile the following:

pod 'Tapstream', '~> 2.8.6'

You can also install Tapstream manually by downloading the latest SDK from: https://tapstream.com/developer/ios/sdk/.

When choosing the manual method, you add the SDK to your project by extracting the SDK zip file and copying the Tapstream folder in your project directory, dragging the Tapstream folder from the Finder window into the Xcode Project navigator. You then add the AdSupport framework in the Linked Frameworks and Libraries area of the General Tab.

Importing and Working with the SDK

You import and initialize the SDK in the -application:didFinishLaunchingWithOptions: method of your AppDelegate class:

#import "TSTapstream.h"
...
TSConfig *config = [TSConfig configWithDefaults];
[TSTapstream createWithAccountName:@"TAPSTREAM_ACCOUNT_NAME" developerSecret:@"TAPSTREAM_SDK_SECRET" config:config];
Using Onboarding Links

The SDK provides a provision for receiving callbacks containing all the information Tapstream has recorded about the user’s timeline, such as links the user has selected on websites your company owns and visited just prior to running the app.

TSTapstream *tracker = [TSTapstream instance];
[tracker getConversionData:^(NSData *jsonInfo) {
    ...
     NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonInfo options:kNilOptions
                                                               error:&error];
      ..
      NSArray *hits = [jsonDict objectForKey:@"hits"];
      NSArray *events = [jsonDict objectForKey:@"events"];
      ...

}];

Tapstream provide an example of what the JSON response might actually look like:

{
  "hits": [
    // This is an array of all hits (e.g. campaign clicks and website visits) associated with this user.
    {
      "custom_parameters": { // All custom query string parameters
        "__deeplink": "trending://stocks/", // If available, the deeplink destination you defined for this platform
        "user_id": "abc123"
      },
      "created": 1383695050683,
      "ip": "199.21.86.54",
      "app": "tapfoliotrending",
      "session_id": "2b3d397e-4674-11e3-a2a0-525400f1a7ad",
      "tracker": "example-campaign", // The slug of the campaign link
      "dest_url_platform": "ANY",
      "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B511 Safari/9537.53",
      "referrer": "",
      "device_specific_hardware_ids": {
        "ios_idfa": "141E8456-3D20-46D1-92F8-8EE0728BE7BF"
      },
      "id": "2b3d608f-4674-11e3-a2a0-525400f1a7ad",
      "dest_url": "http://itunes.apple.com/us/app/stocks-trending-stocks-at-a-glance/id512068016?ls=1&mt=8"
    }
  ],
  "events": [
    // This is an array of all in-app events associated with this user.
    {
      "profile_model": "iPhone5,1",
      "profile_gmtoffset": 4294938496,
      "profile_resolution": "640x1136",
      "created": 1383695183000,
      "ip": "199.21.86.54",
      "app": "tapfoliotrending",
      "profile_sdkversion": "2.4",
      "session_id": "df9b7f5d-ca9c-4ef3-a0b9-1e66795eef5e",
      "package_name": "com.paperlabs.TapfolioTrending",
      "tracker": "ios-trending-open", // The slug of the event
      "profile_os": "iPhone OS 7.0.3",
      "profile_vendor": "Apple",
      "device_specific_hardware_ids": {
        "ios_idfa": "142D8456-4E70-46D1-92F8-8EE0728BE7BF",
        "ios_secure_udid": "EAAD91D5-EAEA-40BC-A244-13A3D7748F95"
      },
      "app_name": "Trending",
      "id": "7a1f50ce-4674-11e3-a312-525400d091e2",
      "profile_locale": "en_US",
      "profile_platform": "iOS"
    },
  ]
}

How are/could deep links be used at your organization? Do you have experience with any of the tools reviewed here? Please let us know your thoughts, insight and recommendations in the comments section.

Be sure to read the next Mobile article: How to Get Started With Apple's ResearchKit

 

Comments (13)

Julie Elangwey

 How to set up Apple Universal Links on iOS 9 to deep link on iPhone app.

walterdf

how do I pass multiple parameters?

programmableweb://news/{paramName1}_{paramValue1}/{paramName2}_{paramValue2}/...

Thanks,

Walter

doronkatz

For that Walter, using components(separatedByString:xxx) and store as an array, access the individual properties, would be a good approach to take

Paulcarder

Java is an amazing language, and the more I learn through the Java forum, the more I get impressed with the way people make use of it for creating websites, mobile games, and apps.

cjsm_menezes

Don,

Nice to meet you.

Do you have this code for Swift ? I have a problem. When my app receives the deep link by Face (https://fb.me/680438488793610) the app falls. Should I made some mystake ?  When I call the app via Safari using the url scheme biblianvt://?a=2&b=3:3 (for example) the app works perfectly.

Thanks for your help

Claudio - cjsm_menezes@yahoo.com.br

cjsm_menezes

claudio

Doron, good morning.

Does that code bring the querystring of the app link URL ? My app publishes a Facebook app link like that: 

https://fb.me/682225125281613?a=7&b=3:7

When user taps in this posts my app should read this querystring after the "?"

Could you send your code in Swift ? I need read the querystring to deal and go to a específic view controller.

 

Thanks

Claudio 

cjsm_menezes@yahoo.com.br

 

 

doronkatz

In addition to my previous post, answering your question Claudio, BF should ideally expose properties similar to:

{ "target_url": "https://www.example.com/abc.html", "extras": { "fb_app_id": [YOUR_FACEBOOK_APP_ID], "fb_access_token": "[ACCESS_TOKEN']", "fb_expires_in": "3600" }, "referer_app_link": { "url": "[FACEBOOK_APP_BACK_LINK]", "app_name": "Facebook" } }

Link

However, in the link I sent you on RayWenderlich, you create an  apple-app-site-association and then implementing:

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {

...

Apps-Kpt

Really appreciate for your amazing article. Keep going on, good stuff. Thank you for this valuable information.   appvn

Click-Hunk

Thanks for sharing this great. Keep sharing more useful and conspicuous stuff like this. Thank you so much.

fastpokemap

bean-Chao

Keep sharing more useful and conspicuous stuff like this. Thank you so much 

 

bean-Chao

Very Helpful Information… 

Thanks for sharing. 

Ammy-Watsan

Hey! it's a very informative post I have developed an application and how to take a deep link, I follow with the deep linking, developers can set up apps so that they contextually redirect a user to a precise location in another app.

Thanks a lot for sharing an Idea of getting deep link!!!!