Real-time Uninstall Tracking

What is real-time uninstall tracking?

Real-time uninstall tracking enables you to track the uninstall immediately after the user uninstalls an app integrated with Firebase Analytics.

The Firebase tracks the event app-remove when an app is uninstalled. The app-remove event is used by MoEngage using Firebase Cloud Functions.

What are Firebase Cloud Functions?

Cloud Functions for Firebase is a serverless framework that programmatically provides responses to events triggered by Firebase features and HTTPS requests. For more information, refer to Cloud Functions for Firebase.

How is real-time uninstall tracking different from the existing uninstall tracking?

The current uninstall tracking in MoEngage happens by sending Silent Push notifications once a day to all user devices. Up to 24 hours is required to track uninstall.

Using the real-time uninstall tracking, the uninstall is tracked immediately by the Firebase SDK so that you can respond quickly to user uninstalls

Implementation of real-time uninstall tracking



Ensure you have the Firebase Blaze plan account.

To deploy Cloud Functions to the runtime environment, your project must be on the Firebase pricing plan.

Set up a common identifier

Ensure your app has integrated Firebase Analytics SDK. For more information, refer to Get started with Google Analytics.

Add the following code in your app to set up a common identifier between MoEngage and Firebase.

val firebaseAnalytics = FirebaseAnalytics.getInstance(this)
firebaseAnalytics.setUserProperty("MOE_USER_ATTRIBUTE_UNIQUE_ID", "<unique-id>")

Note: The following values are not allowed in the UniqueID field: "unknown", "guest", "null", "0", "1", "true", "false", "user_attribute_unique_id", "(empty)", "na", "n/a", "", "dummy_seller_code", "user_id", "id", "customer_id", "uid", "userid", "none", "-2", "-1", "2"

Set up the conversion event using Firebase



Ensure that the App is integrated with Firebase Analytics for real-time uninstall tracking.

Firebase analytics automatically collects the event app_remove. The app_remove event is, an Android-only event, tracked when an application package is removed or uninstalled from the device, regardless of the installation source. To set up a real-time uninstall make sure that the app_remove event is marked as the conversion event on the Firebase dashboard.

To set up a conversion event, follow these steps:

  1. Navigate to Firebase Console and select the Firebase project integrated with the app.

  2. From the Firebase dashboard, select Analytics > Events.

  3. Enable the Mark as Conversion toggle for app_remove event in the event list.

Create Cloud Function

After the conversion event is set up, use the Cloud Function for Firebase to create a function and send the app_remove event to MoEngage.

To create and publish a cloud function using Node JS, follow these steps:

  1. Install Node.js and npm.
    Node.js environment is required to write functions. Use the Firebase CLI to deploy functions to the Cloud Functions runtime. 

  2. Install Firebase CLI using the following code:

    CLI Command
    npm install -g firebase-tools
  3. Run firebase login to log in using the browser and authenticate the firebase tool.

  4. Navigate to your Firebase project directory.

  5. Run firebase init functions.

  6. Select Javascript as a language option.

  7. Add the following code to the index.js file:
    "use strict";
    const functions = require("firebase-functions");
    const admin = require("firebase-admin");
    const https = require("https");
    exports.sendAndroidUninstallToMoEngage ="app_remove")
        .onLog((event) => {
          console.log("sendAndroidUninstallToMoEngage() : Event is: " +
          return exports.sendAppUninstallEventData(event);
    exports.sendAppUninstallEventData = function(event) {
    //fetch the unique ID <MOE_USER_ATTRIBUTE_UNIQUE_ID>
    var uniqueId = event.user.userProperties.MOE_USER_ATTRIBUTE_UNIQUE_ID.value;
    //send event using S2S API of MoEngage
  8. Add the following code to package.json file:
      "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": "12"
      "main": "index.js",
      "dependencies": {
        "firebase-admin": "^10.0.0",
        "firebase-functions": "^3.16.0",
        "firebase-tools": "^9.23.0",
        "g": "^2.0.1",
        "requestretry": "^4.1.1"
      "devDependencies": {
        "eslint": "^7.6.0",
        "eslint-config-google": "^0.14.0",
        "eslint-plugin-promise": "^4.0.1",
        "firebase-functions-test": "^0.2.0",
        "requestretry": "^4.1.1",
        "web-push": "^3.4.5"
      "private": true




Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?