Skip to main content
Android Uninstall Tracking

Android Uninstall Tracking

Updated over 5 months ago

At a Glance : Android Uninstall Tracking has become easier with Trackier Apptrove. The Trackier Apptrove gives you the option of tracking Android App Uninstalls in real-time, as another way to measure the quality of traffic and restrict frauds as well.


Setting up or enabling Android Uninstall Tracking is a simple three-step process and you can complete it on own following the simple steps mentioned below

1. Set Up A Common Identifier

Add the following code to Your Application to initiate setting up a common identifier.

private FirebaseAnalytics mFirebaseAnalytics;

FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

mFirebaseAnalytics.setUserProperty("ct_objectId", Objects.requireNonNull(TrackierSDK.getTrackierId()));


Besides, setting up a common identifier, you can track the following fields while performing the uninstalls:

  • (optional) Application mode:

mFirebaseAnalytics.setUserProperty("ct_mode", Objects.requireNonNull(""));

  • (optional) Customer user ID:

mFirebaseAnalytics.setUserProperty("ct_uid", Objects.requireNonNull(""));

  • (optional) Customer email:

mFirebaseAnalytics.setUserProperty("ct_mail", Objects.requireNonNull(""));

2. Set up conversion event using firebase

Though the firebase analytics automatically collects the app_remove event, still you will be required to enable that.

This is an Android-only event that is tracked when an application is uninstalled from the device.

Follow the below-mentioned steps to complete the set-up process:

  1. Navigate to the firebase console and select the firebase project that is integrated with your android application.

  2. Navigate to Analytics > Events in the Firebase Dashboard.

  3. Enable the “Mark as conversion” toggle for the app_remove event.


3. Set up the cloud function to communicate uninstall data with Trackier

After the conversion is set up, use the cloud function for Firebase to create a function and send the uninstall data to Trackier Apptrove.


Pre-requisites:

  1. Your system should have nodejs (https://nodejs.org/en/) installed, preferably version 18 or higher. Run the following command to check the installed nodejs version node -v.

  2. Please make sure that your user in the application’s project on google cloud platform has the permission to create a cloud function here: https://console.cloud.google.com/functions/list

To create and publish a cloud function using Node JS, perform the following steps:

  1. Open a terminal.

  2. Set up Node.js and the Firebase CLI.

  3. Run npm install -g firebase-tools.

  4. To initialize Firebase SDK for Cloud Functions, run firebase login.

  5. From your Firebase project directory, run firebase init functions.

  6. Select Javascript as a language option.

  7. Move to the functions directory, run cd functions.

  8. Open index.js and add the following code:

// Import dependencies

const functions = require("firebase-functions");

const admin = require("firebase-admin");

const axios = require("axios");


// Configure SDK Key here

const SDK_KEY = "";


// Initialize application via firebase admin

admin.initializeApp();


// Set function to exports

exports.sendAndroidUninstallToTrackierApptrove = functions.analytics.event("app_remove").onLog((event) => {

// Extract values from user properties

const installId = (event.user.userProperties.ct_objectId) ? event.user.userProperties.ct_objectId.value : "";

const mode = (event.user.userProperties.ct_mode) ? event.user.userProperties.ct_mode.value : "";

const cuid = (event.user.userProperties.ct_uid) ? event.user.userProperties.ct_uid.value : "";

const cmail = (event.user.userProperties.ct_mail) ? event.user.userProperties.ct_mail.value : "";


// Prepare data for request

const data = JSON.stringify({ installId, sdkKey: SDK_KEY, mode, cuid, cmail, meta: event });



// Send data back to Trackier Apptrove

axios.post(url, data, { headers: { "Content-Type": "application/json" } })

.then((response) => console.log(JSON.stringify({ installId, status: response.status, data: response.data })))

.catch((error) => console.error(JSON.stringify({ installId, status: error.response.status, data: error.response.data })));

});

  1. Open package.json and add the following code:

{

"name": "functions",

"description": "Cloud Functions for Firebase",

"scripts": {

"lint": "eslint .",

"serve": "firebase emulators:start --only functions",

"shell": "firebase functions:shell",

"start": "npm run shell",

"deploy": "firebase deploy --only functions",

"logs": "firebase functions:log"

},

"engines": {

"node": "18"

},

"main": "index.js",

"dependencies": {

"axios": "^0.24.0",

"firebase-admin": "^10.0.1",

"firebase-functions": "^3.16.0"

},

"devDependencies": {

"eslint": "^8.6.0",

"firebase-functions-test": "^0.3.3"

},

"private": true

}

  1. Open .eslintrc.js and add the following code, create one if does not exist:

module.exports = {

root: true,

env: {

es6: true,

node: true,

},

extends: [

"eslint:recommended",

],

rules: {

quotes: ["error", "double"]

},

};

  1. Install all dependencies, run npm install.

  2. Deploy the cloud function, run npm run deploy.

  3. Once deployed, you can monitor the status of your cloud function here:
    https://console.cloud.google.com/functions/list



We are delighted to have assembled a world-class team of experienced professionals who are ready to take care of your queries and answer any questions you may have. Feel free to reach out to us at anytime through emailing us at support@apptrove.com or by using the in-platform chat feature. We'd love to hear from you!



Did this answer your question?