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.”


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: “}}/{{ productId:”242122244"}}

We would re-direct the destination URL as follows:

/products –> /products? –>

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:

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
      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": "",
      "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": ""
  "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": "",
      "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