How to track USSD flows in your Android app
USSD is how hundreds of millions of Africans access mobile money, banking and government services. If your app triggers a USSD flow — for airtime top-up, M-Pesa payments, or bank transfers — you need to track what happens in that flow.
The problem: once a USSD session starts, your app is backgrounded. Standard analytics tools see this as a session end. You lose visibility into the most important part of the user journey.
The approach
Unilitix lets you manually track USSD entry and result events, wrapping the opaque USSD session with context from your app.
Step 1 — Track USSD initiation
Before you launch the USSD intent, fire a custom event:
Unilitix.trackEvent("ussd_initiated", mapOf(
"code" to "*737#",
"purpose" to "airtime_topup",
"amount" to 500
))Step 2 — Launch the USSD intent
val ussdCode = Uri.encode("*737*100*500#")
val callIntent = Intent(Intent.ACTION_CALL,
Uri.parse("tel:$ussdCode"))
startActivity(callIntent)Step 3 — Track the result in onResume
When your app returns to the foreground, record the outcome:
override fun onResume() {
super.onResume()
Unilitix.trackEvent("ussd_returned", mapOf(
"purpose" to "airtime_topup",
"duration_ms" to elapsedMs
))
}Step 4 — Confirm with your backend
When your backend receives confirmation of the USSD transaction, fire a server-side event via the REST API:
curl -X POST https://api.unilitix.com/v1/events \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"event":"ussd_confirmed","userId":"u_123"}'What you get
With these three events — initiated, returned, confirmed — you can build a funnel that shows exactly how many users start a USSD flow, how many return to your app, and how many complete the transaction. For fintech apps, this is often the most important funnel in the product.