100% Matching Accuracy with iOS 9 Safari View Controller

Branch is excited to announce that we now offer 100% accurate install attribution for clicked links on iOS 9.

With iOS 9, Apple has given developers some great gifts. Two of my favorites are Universal Links and the Safari View Controller, both of which allow for a more seamless user experience across apps. For the sake of this post, let’s focus on using Safari View Controller to power perfect install attribution.

Using Safari View Controller for Install Attribution

Prior to iOS 9, you could only pass data through the App Store using a Apple-provided banner. This banner was not customizable at all. To fix this, we crafted a solution using digital snapshotting and javascript redirects. Our solution allows developers to get individual-level install attribution—meaning they can know the exact link a user clicked even if they clicked it before the app was installed. (And by the way, we created a fully customizable app download banner for those who love banners.)

That all changes with a new feature in iOS 9. The Safari View Controller allows developers to pull up a full-screen, Safari-like window for accessing web pages. This is different from viewing web pages prior to iOS 9 (in UIWebView and WKWebView) in that it is effectively a sandbox, with almost everything hidden from the developer. Also, it’s a view controller, not a view that can be embedded in other views.

Perhaps most crucially–and this is why we love it–cookies are shared between all the iOS View Controller and Safari. Put another way, cookies for a given site can be shared across all apps.

This is great news! This means that you can seamlessly transition users from your mobile website to your app. If a user is logged into your site in Safari then downloads your app, you can open up SFSafariViewController, navigate to www.yoursite.com/welcome-user, and display a page welcoming that person to your app.

At Branch, we’ve offered this for about a year now, using a technique called “digital snapshotting”. We use a combination of a user’s operating system, operating system version, and IP address to compare users clicking on links in the browser to users opening apps.

Digital snapshotting is imperfect but works the vast majority of the time, and we only have to use it once per device. Then we have them tagged based on browser cookie and IDFA. We’ve described this process in more detail on our developer portal: https://docs.branch.io/resources/matching/

However, with iOS 9, we no longer need to resort to digital snapshotting.

iOS View Controller for 100% Matching

Practically speaking, you can’t just open up SFSafariViewController and read the cookies from any website (that would be terrifying). In reality, cookies dropped in Safari are attached to requests made in SFSafariViewController, and vice versa.

The team at Apple responsible for the iOS View Controller has clearly decided that security is a top priority here. In fact, security and protecting user data is a large part of the branding surrounding iOS 9.

If you use Branch for 100% matching, please be sure to include the SafariServices framework as an optional dependency. When opening SFSafariViewController, you can specify an initial page to load and whether to use the reader view if it’s available. For delegate methods, you can see when the first page has loaded, and when the user taps close. There’s not much you can do, but it’s enough.

We’re using this view controller in a creative way to offer 100% matching. That is, we can tell you 100% of the time if a user clicked on a link and what link they clicked on, even if their digital snapshots are identical.

SFSafariViewController *safController = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:urlString]];
safController.delegate = self;
[windowRootController presentViewController:safController animated:NO completion:NULL];

At Branch, we’ve decided on a simple approach:

    1. In the iOS app, create a URL pointing to our servers and including a unique identifier for the device, like IDFA.
    1. Open the SFSafariViewController and point it to that URL
  1. Server-side, the API endpoint receives the IDFA and parses the cookie (if any) sent up with the request. We send down a new cookie if it didn’t exist previously. We now have a link between the user in the browser (cookie) and the user in the app IDFA.

Developers using Branch already have this ability, but now we can avoid the edge cases inherent in snapshotting. When you upgrade to an iOS 9-compatible version of the iOS SDK, you will automatically be making use of Safari View Controller for 100% matching. That means no extra work for you! Click the Get Started button below to visit our dev portal and learn more about the Branch SDK.