Analytics for App Links

Facebook makes it easy to learn how people are using App Links in your app. By understanding and analyzing trends about traffic and usage information with App Links, you can better understand the value of App Links and create better experiences for people.

Setup is only a few lines of code if you're using the Bolts SDK on iOS or Android. The Bolts SDK is included in the Facebook SDK. Results are available in Facebook's Insights Dashboard or through the insights endpoint of the Graph API. The events which you can measure are delievered as App Events. App Events are used to measure other types of events in your app as well, so you access the results through the general App Events framework.

Events

These are the App Links-related events that can be generated by the Bolts SDK:

  • Handling Incoming Links: When an app opens an incoming App Links URL or intent, an event is sent from the receiving app. The event is called al_nav_in.
  • Navigating Out: When your app handles an App Links URL and navigates out, an event is sent from the sending app. The event is called al_nav_out.
  • Navigating Back (iOS Only): When someone navigates back to the sending app from the receiving app by tapping on the navigate back bar, an event is sent from the receiving app. The event is called al_ref_back_out.

Each App Event can include extra fields that give more data about the event:

  • al_nav_out & al_ref_back_out -
  • outputURL: The URL used to open the other app (or browser). If there is eligible app to open, the value will be the custom scheme url/intent with al_applink_data.
  • outputURLScheme: The scheme of outputURL
  • sourceURL: The URL of the page hosting applink meta tags
  • sourceURLHost: The hostname of source URL
  • success: “1” to indicate success in opening the App Link in another App or Broswer; “0” to indicate failure to open the App Link
  • type: “app” for open in app, “web” for open in browser; “fail” when the success field is “0”
  • version: App Link API version
  • al_nav_in -
  • inputURL: The url that opens the app.
  • inputURLScheme: The scheme of inputURL
  • refererURL: The URL that the referrer app added into al_applink_data: referer_app_link
  • refererAppName: The app name that the referrer app added to al_applink_data: referer_app_link
  • sourceApplication: The bundle of referrer application
  • targetURL: The target_url field in al_applink_data
  • version: App Link API version

In order to use the functionality included in the Facebook SDK you must:

  1. Update your Facebook SDK (and Bolts SDK) to at least version 3.17.1 on iOS or 3.17.2 on Android.
  2. Make sure the Facebook SDK is properly initialized before trying to send events.

iOS

Update the Bolts Framework, as mentioned above.

The Facebook SDK will automatically be initialized when the UIApplicationDidFinishLaunchingNotification event is sent to your app.

To generate an event when handling an incoming link, we've provided an example you can use in your app's application delegate to parse incoming links. The [BFURL URLWithInboundURL:url sourceApplication:sourceApplication] method will generate an App Event if the incoming URL is an App Link event.

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
  BFURL *parsedUrl =
    [BFURL URLWithInboundURL:url sourceApplication:sourceApplication];
  if (parsedUrl.appLinkData) {
    // This is AppLink traffic
    NSURL *applinkTargetUrl = parsedUrl.targetURL;
  } else {
    // Not an Applink URL, handle differently
  }
}

Android

Update the Bolts Framework, as mentioned above.

Use the following function to parse inbound URLs:

AppLinks.getTargetUrlFromInboundIntent(Context, Intent);

The Facebook SDK needs to be initialized before getTargetUrlFromInboundIntent is called in order to register the App Links event listener before the App Links events are sent.

Here's some sample code you can use in your base activity:

onCreate() {
  Settings.sdkInitialize(this); 
  Uri applinkTargetUrl =
    AppLinks.getTargetUrlFromInboundIntent(this, getIntent());
     if (applinkTargetUrl != null) {
        // This is an AppLink URL, handle it in your app
     }
     // Your code
}

Navigating to outbound App Links is automatically reported as an App Event as long as you're using version 3.17.1 (iOS) / 3.17.2 (Android) or later of the Facebook SDK, and you're using the matching Bolts SDK.

Results

App Links events data can be accessed by either the Graph API or browsing App Insights.

Existing App Launch Events and new TimeSpent Event

Learn more about setting up events for app launch for iOS and Android.

App Launch Event and TimeSpent Event have new “sourceApplication” parameters for these two events, so that the breakdown by different sources for launches can be visible by using “sourceApplication” as an Extra Filter.

App Launch Event:

https://www.facebook.com/insights/<YOUR-APP-ID>?section=AppEvents&amp;event_name=fb_mobile_activate_app&amp;card=breakdown_table

App Time Spent Event:

https://www.facebook.com/insights/<YOUR-APP-ID>?section=AppEvents&amp;event_name=fb_mobile_deactivate_app&amp;card=breakdown_table

Applinks-specific Events

The three events will be added with a prefix of “bf_” (meaning they are forwarded from Bolts Framework) in App Events. You can understand the makeup of users engaging with your app including age, gender, language and country.

App Insights:

Navigate In:

https://www.facebook.com/insights/<YOUR-APP-ID>?section=AppEvents&amp;event_name=bf_al_nav_in

Navigate Out:

https://www.facebook.com/insights/<YOUR-APP-ID>?section=AppEvents&amp;event_name=bf_al_nav_out

Navigate Back to Referer:

https://www.facebook.com/insights/<YOUR-APP-ID>?section=AppEvents&amp;event_name=bf_al_ref_back_out

Graph API:

You can also fetch this data via Graph Insights API:

1. Getting daily data

http://graph.facebook.com/v2.1/app_insights/app_event/?event_name=bf_al_nav_in&amp;aggregateBy=COUNT&amp;since=<STARTTIME>&amp;until=<ENDTIME>&amp;access_token=<YOUR-ACCESS-TOKEN>

2. Getting daily data by client type:

http://graph.facebook.com/v2.1/app_insights/app_event/?event_name=bf_al_nav_in&amp;aggregateBy=COUNT&amp;since=<STARTTIME>&amp;until=<ENDTIME>&amp;breakdowns[0]=client&amp;access_token=<YOUR-ACCESS-TOKEN>&amp;date_format=U

3. Getting daily launch data by source:

http://graph.facebook.com/v2.1/app_insights/app_event/?event_name=fb_mobile_activate_app&amp;breakdowns[0]=souceApplication&amp;aggregateBy=COUNT&amp;since=&amp;until=&amp;breakdowns[0]=client&amp;access_token=&amp;date_format=U