Skip to main content

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.

ConceptWhat it means
UninstallThe device no longer has your app. Adtrace detects this with a daily silent push.
ReinstallThe app was uninstalled, then installed and opened again later.
Push tokenThe FCM token for the device. You must send it to the SDK with AdTrace.setPushToken.
Silent pushA data message with no user-visible notification. Adtrace sends one about once per day.
tip

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

RequirementDetails
Adtrace Android SDKUse the latest release
Firebase in your appAdd Firebase to your Android project
FCM HTTP v1 keyCreate a service-account JSON key and upload it in the Adtrace panel
Panel setupComplete uninstall / reinstall settings for your app in the panel
warning

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

  1. Open the Google Cloud Console.
  2. Select the Google Cloud project linked to your Firebase project.
  3. Go to IAM & AdminRoles.
  4. Select + Create Role.
  5. Enter:
    • Title: Adtrace Uninstall
    • ID: adtrace_uninstall
    • Role launch stage: General Availability
  6. Select + Add Permissions.
  7. Search for cloudmessaging.messages.create, select it, then Add.
  8. Select Create.

Create a service account

  1. In IAM & Admin, open Service Accounts.
  2. Select + Create Service Account.
  3. Service account name: Adtrace Uninstall Service Account.
  4. Select Create and Continue.
  5. Under Select a role, search for Adtrace Uninstall and select that role.
  6. Select Continue, then Done.

Generate and download the private key

  1. Open the new service account (email looks like adtrace-uninstall-service-account@project-id.iam.gserviceaccount.com).
  2. Open the Keys tab.
  3. Select Add KeyCreate new key.
  4. 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:

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)
ParameterTypeDescription
tokenStringThe FCM push notification token for the device
contextContextAndroid context. Prefer getApplicationContext() / applicationContext
Recommended overload

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

AdTrace.setPushToken(pushNotificationsToken, getApplicationContext());

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:

  1. Upload the FCM HTTP v1 JSON key in the panel
  2. Initialize Firebase and the Adtrace SDK
  3. Call AdTrace.setPushToken whenever the token is available or changes
  4. Handle silent pushes correctly if you show your own notifications

…uninstall and reinstall measurement runs automatically.

Next: Examples · Test the integration