Deep linking in iOS and Android - The Signal 
Blog Post

Community Tip: Setting up Deep Linking in iOS and Android

This Community Tip will walk developers through mobile deep linking via Mixpanel’s In App Notifications. For both iOS and Android mobile, we will describe the code changes and describe how to include deep links with Mixpanel notifications.

Why are deep links useful?

Deep links create an experience that links users directly to the content they desire. In today’s mobile ecosystem, moving between applications or within applications can be friction-filled and lead to low conversions. For example, when sending a notification to have your users try a new feature, a deep link can point users precisely to the relevant view. Creating a flexible deep link architecture in your application and using tools like Mixpanel’s People Notifications allows your mobile team to drive user engagement to precise locations quickly and effectively.

In the next sections, we’ll take you through the steps to enable deep linking in iOS and then Android. Both require changes to your application build. We’ll also describe how to create notifications in Mixpanel that utilize these.

The iOS and Android examples are available in sample apps here: iOS, Android.

iOS (Objective-C)

In iOS we need to follow a three-step process to set up deep linking. The first two steps will require changes to your Xcode build. Our examples will be in Objective-C.

First, we need to register a custom URL within Xcode. Having a custom URL scheme gives your application a name iOS can recognize. When presented with your unique URL, iOS will open your application. Next, we need to update our AppDelegate.m to listen for additional parameters on the URL. While step 1 helps iOS know to open your application, step 2’s AppDelegate alteration provides direction as to what screen the user should see on app open. Finally, in step 3 we’ll deliver a deep link through Mixpanel in-app notifications. This is one effective way to make your notifications experience harmonious.

Step 1 – Register a custom URL

1a. In your Xcode project, we will need to register a custom URL identifier. Access your info.plist file within your Supporting Files. Add a new row for URL Types. Expand Item 0 and create a URL identifier. Best practices assert naming your domain in reverse: com.mixpanel.Deeplinkapp. For our purposes, we will not need to reference this URL identifier later.

1b. Under Item 0 we can add a new row to create a URL scheme. This gives your application the specific naming convention. Now, when iOS is presented with your registered URL scheme, it knows to launch your application.
Under the URL Type, there is a new row categorized as URL Schemes. Its string is set to "mixpanel."
In your iOS simulator, test the URL scheme by opening Safari and entering in your scheme. Your application should launch:


Step 2 – Listen for custom URLs

2a. Your URL scheme will open your application to its home screen. We next want to direct a user to a specific view other than the home screen. The format of these URLs are scheme, host, and path: scheme://[host]/[path]. The scheme launches the application, and the host and the path move the user to a separate screen within the application. Let’s update our AppDelegate’s default behavior to listen for a host and a path. Add the following code to your AppDelegate. This allows for additional parameters to be passed into a custom URL:

-(BOOL)application:(UIApplication *)application
 openURL:(NSURL *)url
 sourceApplication:(NSString *)sourceApplication

2b. Now we need to update this listener to look for a specific host and path. Below shows an if statement that directs a user to the correct view controller given a match. If mixpanel://deeplink/page1 is clicked, it will direct to the Page1ViewController, a separate screen from the home view.

This code snippet alters the previous function:

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    if([[url host] isEqualToString:@"deeplink"]) {
        if([[url path] isEqualToString:@"/page1"]) {
            self.window.rootViewController = [[Page1ViewController alloc] init];
        } else if ([[url path] isEqualToString:@"/page2"]) {
            self.window.rootViewController = [[Page2ViewController alloc] init];
        } else {
            return NO;
    } else {
        return NO;
    return YES;

Step 3 – Deliver deep link through Mixpanel

Finally, now that your application is set up to listen for specific information, let’s send that information over through Mixpanel!
In the Notifications tab, there is a field below touch actions. When your user taps your notification's call to action, you can order your application to ope n a link in or outside of your app. This field can be a weblink such as or a deep link like fb://profile/33138223345. Deep links allow apps to open specific pages in other apps such as Maps, Facebook, and the App Store using a customer protocol described on Wikipedia.

Our link will be: mixpanel://deeplink/page1. Any user who has our application on their phone will be directed to ‘page1’ attached to the Page1ViewController.
This is page1, what the user will see after touching the deep linking action.

Android Java

In Android, the deep link setup requires creating an intent filter to register a URL scheme. Upon the creation of an intent filter, we’ll utilize the data provided by the intent to determine which screen to render.

Registering URI with Action, data, category

Three elements within an intent are action, data, and category.
Action describes what the user is trying to do. Data describes the specific URI that was clicked on. Category allows an intent filter to be accessible from either a web browser or an implicit intent by including BROWSABLE and DEFAULT. For more, feel free to read the Android documentation under ‘Add Intent Filters For Your Deep Links’.

We will wrap these elements in an intent filter within your Android Manifest. Below, you’ll see we utilize the data element to register a URL scheme mpdeeplink://. Moreover, we’ve added a host called ‘newcontent’. Now, when given mpdeeplink://newcontentpage, our AndroidManifest is prepared to execute an action.

Handling the intent

Android has instantiated an activity in respect to the intent filter you have set up. Now, we can set up an intent handler to appropriately direct the user to the screen associated with the provided scheme and host. We’re retrieving the intent data within onCreate, and can use ‘Uri data’ to create an activity. The below activity shows an alert and tracks an event.

public class NewContentActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        if (getIntent().getAction() == Intent.ACTION_VIEW) {
            Uri data = getIntent().getData();
            if (data != null) {
                // show an alert with the "custom" param
                new AlertDialog.Builder(this)
                        .setTitle("Welcome to New Content!")
                        .setMessage("Found custom param: " +data.getQueryParameter("custom"))
                        .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
        // send a Mixpanel event
        MixpanelAPI mMixpanel = MixpanelAPI.getInstance(this, MainActivity.MIXPANEL_API_TOKEN);
        mMixpanel.track("in app activity event", null);

Deliver through Mixpanel in-apps

Once you’ve created an activity for your users, test it with the Mixpanel web app. Utilize the ‘Touch Actions’ field in the in-app message creation builder to fill in your custom URL.

Fill your custom URL into the Touch Actions field to enable deep linking.

And that’s it! Deep linking is a fantastic way to make your users’ experiences more seamless. Maximize your Mixpanel notification campaigns with a smooth and consistent call-to-action – you can even A/B test your notifications to see which call to action performs the best!

Any questions? Email us at to speak with someone smart, quickly.

Get the latest from Mixpanel
This field is required.