RTN Docs

Android SDK · Preview

Attribution and deep links

Attribute installs to campaigns, route direct and deferred deep links, and connect push notifications on Android.

Preview: planned API

The Android SDK is in development and not published yet. This page describes the API we are building so you can plan your integration. Package names, signatures and defaults may still change before the first release.

Install attribution

On the first launch the SDK sends an install with the signals the platform allows. The server matches it against clicks on RTN tracking links and ad engagements, checks it for fraud, and returns the winning source.

On Android the SDK reads the Google Play Install Referrer on first launch and sends it with the install. No extra dependency is needed.

// Resolves once the server has matched the install, or falls back
// to the local Play Install Referrer snapshot after the timeout.
lifecycleScope.launch {
    val attribution = RTN.awaitAttribution(timeoutMillis = 2_000)
    Log.d("RTN", "network=${attribution?.network} campaign=${attribution?.campaignId}")
}

// Synchronous local snapshot, or null without consent
val local = RTN.getAttribution()

The attribution contains the network, campaign_id, click_id, matched_by (deterministic or probabilistic) and, when the click carried one, the deferred_deep_link. Probabilistic matching is used only when the probabilistic_attribution purpose is granted.

Pass incoming links to the SDK so it can record deep_link_opened with campaign parameters. Register one listener for both direct links and deferred links, which arrive on the first launch after an install from an RTN tracking link.

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        RTN.handleDeepLink(intent)

        RTN.onDeepLink { link ->
            // link.url, link.isDeferred, link.campaignId
            navController.navigate(link.url)
        }
    }

    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)
        RTN.handleDeepLink(intent)
    }
}

Push notifications

Register the device push token so RTN journeys can reach the customer with push, and report opens so they count toward journey results.

class ShopMessagingService : FirebaseMessagingService() {
    override fun onNewToken(token: String) {
        RTN.setPushToken(token)
    }
}

// When the user opens a notification
RTN.trackPushOpened(intent.extras)

Send before leaving the app

Call flush before you hand the customer to another app, such as a payment provider, so the last events are not delayed until the next launch.

lifecycleScope.launch {
    RTN.flush()
    startActivity(paymentIntent)
}

On this page