Uninstall / Reinstall tracking
Use the Adtrace Android SDK to measure uninstalls and reinstalls. Adtrace sends silent push notifications using the device push token, then checks whether your app is still installed.
| Concept | What it means |
|---|---|
| Uninstall | The device no longer has your app. Adtrace detects this with a daily silent push. |
| Reinstall | The app was uninstalled, then installed and opened again later. |
| Push token | The FCM token for the device. You must send it to the SDK with AdTrace.setPushToken. |
| Silent push | A data message with no user-visible notification. Adtrace sends one about once per day. |
Uninstall and reinstall measurement works for apps from any store or direct download if the device has Google Play Services. Devices without Google Play Services (for example some Amazon or Huawei devices) are not supported.
Before you begin
| Requirement | Details |
|---|---|
| Adtrace Android SDK | Use the latest release |
| Firebase in your app | Add Firebase to your Android project |
| FCM HTTP v1 key | Create a service-account JSON key and upload it in the Adtrace panel |
| Panel setup | Complete uninstall / reinstall settings for your app in the panel |
Firebase Cloud Messaging Legacy APIs are deprecated. Use FCM HTTP v1 only. Generate a new JSON private key; do not reuse a legacy server key. See Google’s migrate to HTTP v1 guide.
1. Connect Google FCM to Adtrace
Silent push through Google’s Firebase Cloud Messaging (FCM) API lets Adtrace measure uninstalls and reinstalls. Adtrace needs an FCM HTTP v1 service-account private key (JSON) to call FCM.
Create a custom role
- Open the Google Cloud Console.
- Select the Google Cloud project linked to your Firebase project.
- Go to IAM & Admin → Roles.
- Select + Create Role.
- Enter:
- Title:
Adtrace Uninstall - ID:
adtrace_uninstall - Role launch stage: General Availability
- Title:
- Select + Add Permissions.
- Search for
cloudmessaging.messages.create, select it, then Add. - Select Create.
Create a service account
- In IAM & Admin, open Service Accounts.
- Select + Create Service Account.
- Service account name:
Adtrace Uninstall Service Account. - Select Create and Continue.
- Under Select a role, search for
Adtrace Uninstalland select that role. - Select Continue, then Done.
Generate and download the private key
- Open the new service account (email looks like
adtrace-uninstall-service-account@project-id.iam.gserviceaccount.com). - Open the Keys tab.
- Select Add Key → Create new key.
- Choose JSON, then Create.
The JSON file downloads to your machine. Upload that file in the Adtrace panel for your app’s FCM / uninstall connection.
Example shape of the downloaded JSON (values are placeholders):
{
"type": "service_account",
"project_id": "app_name",
"private_key_id": "some_private_key",
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
"client_email": "adtrace-uninstall-service-acco@app_name.iam.gserviceaccount.com",
"client_id": "6152715792181423123124",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/adtrace-uninstall-service-acco%40app_name.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
2. Add Firebase Messaging to your app
Add the Firebase Messaging dependency if you do not already have it:
- Kotlin (build.gradle.kts)
- Groovy (build.gradle)
dependencies {
// Use a current firebase-messaging version, or the Firebase BoM
implementation("com.google.firebase:firebase-messaging:23.4.0")
}
dependencies {
// Use a current firebase-messaging version, or the Firebase BoM
implementation 'com.google.firebase:firebase-messaging:23.4.0'
}
Set up an FCM client if you have not already: follow Google’s FCM Android setup.
Initialize Firebase before you call AdTrace.onCreate(). See Examples.
3. Send the push token to the SDK
Push tokens are required for uninstall and reinstall tracking. After you obtain the FCM token (and whenever it changes), pass it to Adtrace.
Method signature
public static void setPushToken(String token, Context context)
| Parameter | Type | Description |
|---|---|---|
token | String | The FCM push notification token for the device |
context | Context | Android context. Prefer getApplicationContext() / applicationContext |
Prefer AdTrace.setPushToken(token, context). The context argument covers more cases so the token is sent reliably. The older AdTrace.setPushToken(token) overload (no context) still works for native apps, but is not preferred.
Native SDK example
- Java
- Kotlin
AdTrace.setPushToken(pushNotificationsToken, getApplicationContext());
AdTrace.setPushToken(pushNotificationsToken, applicationContext)
WebBridge / WebView SDK
AdTrace.setPushToken(pushNotificationsToken);
4. Handle silent push notifications
Adtrace sends a silent push about once per day to check install status. If your app also sends its own notifications, override onMessageReceived in FirebaseMessagingService so you do not treat Adtrace silent pushes as user-visible alerts.
A simple check (from the SDK README): treat a data message with no title and no body as silent:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (remoteMessage.getData().get("title") == null
&& remoteMessage.getData().get("body") == null) {
// Silent push (for example Adtrace uninstall check). No UI.
} else {
// Handle your own notifications
}
}
For a fuller FirebaseMessagingService (token refresh + optional Util.isAdTraceUninstallDetectionPayload), see Examples.
5. Ready to measure
After you:
- Upload the FCM HTTP v1 JSON key in the panel
- Initialize Firebase and the Adtrace SDK
- Call
AdTrace.setPushTokenwhenever the token is available or changes - Handle silent pushes correctly if you show your own notifications
…uninstall and reinstall measurement runs automatically.
Next: Examples · Test the integration