Deeplinking with your app

Deeplinking is a methodology for launching a native mobile application via a link. It connects a unique url to a defined action in a mobile app, seamlessly linking users to relevant content.

This guide will cover how to enable deeplinking for trck.at tracking links.

A deeplink functions much like a traditional hyperlink on a webpage. It is composed of separate elements that make up what is referred to as a Uniform Resource Identifier (URI). The URI contains all the information that, when invoked, launches a mobile application with a specific screen.

When thinking about deeplink structure, the best practice is to implement a URL with a unique scheme name and routing parameters (host and query strings) that represent custom actions to take in the app.

Deeplink url

Overview

Setting up trck.at deeplink to open your app involves two steps:

  1. Firstly, configure the DeepLink's Schema/Intent Filter & Host of the Deeplink in your Dashboard Account Settings.
  2. Once the deeplink is configured in Dashboard settings, it needs to be enabled in the App. The sections below cover this in detail for Android & iOS platforms.

Go to accounts page of your dashboard and fill in the DeepLink urls.

Deeplink settings

  • The activity specified to handle this Deeplink in your app's AndroidManifest.xml will be invoked when the tracking link is opened on the device. Refer to Android's documentation on deeplinking here for more information.

  • On opening trck.at tracking link, it will be redirected to the custom url configured in the Dashboard Settings. When this activity's onCreate method is called, you can recover the URL from the Intent params that was used to launch it and process it according to your needs as depicted below.

private String actionID;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...

    // If Activity Started through deep link
    Intent intent = getIntent();
    if (intent != null && !TextUtils.isEmpty(intent.getDataString())) {
        handleAppDeepLink(MainActivity.this, intent.getData());
        return;
    }
}

private void handleAppDeepLink(Context context, Uri uri) {
    if (uri != null) {
        try {
            // Check if Scheme & Host for this link matches the one specified in Dashboard settings
            if (uri.getScheme() != null && uri.getHost() != null
                && uri.getScheme().equalsIgnoreCase("<scheme_specified_in_dashboard>")
                && uri.getHost().equalsIgnoreCase("<host_specified_in_dashboard>")) {

                Set<String> queryParamNames = uri.getQueryParameterNames();
                if (queryParamNames == null || queryParamNames.isEmpty()) {
                    // Handle No Params Intent here
                    return;
                }

                for (String paramName : queryParamNames) {
                    switch (paramName) {
                        case "action_id":
                            actionID = uri.getQueryParameter(paramName);
                            break;
                    }
                }    

                // Handle Intent here (Use Query Params like actionID etc.)
                ...
            }
        } catch (Exception e) {
          e.printStackTrace();
        }
    }
}

results matching ""

    No results matching ""