Uninstall Tracking

  1. There could be multiple reasons why a user might decide to uninstall an application such as unsatisfactory app performance, technical flaws, poor user experience, excessive memory and data usage, etc.
  1. Tracking app uninstalls can yield valuable insights into user churn and help devise ways to enhance retention.

Track Uninstalls

NotifyVisitors tracks app uninstalls in the following ways:

  • Silent Push Notification: By means of sending a silent push notification daily.
  • Real-time: As soon as a user uninstalls the app (this is available exclusively for Android devices)
  • Push Notification Campaign: When a push notification can’t be delivered due to an invalid/expired token.

Silent Push Notifications (iOS & Android)

  1. A silent notification is a simple yet effective means to verify token validity. An invalid token usually indicates that the app has been uninstalled.
  1. NotifyVisitors uses silent push notifications to track app uninstalls for both Android and iOS applications. A silent push notification contains an empty message that is sent to the user's device via the Firebase Cloud Messaging (FCM) server for Android devices or Apple Push Notification service (APNs) for iOS devices.
  1. The ‘Mobile App’ section of the software helps you monitor your app uninstalls and thereby take timely action.

📘

Note

Change in app uninstall tracking for android devices

May 15, 2024 onwards, FCM is implementing changes regarding stale tokens for devices not connected to FCM in over 270 days. Such tokens are considered expired and invalid. Consequently, any push notification request sent to stale tokens will fail and return a 404 error (unregistered).

Whom does this change impact?

The change solely impacts customers relying on the Silent Push Notification method for uninstall tracking.

Impact of this implementation

With this change, FCM will return a 404 error (unregistered) from inactive apps, i.e., ones that reach and exceed 270 days of inactivity. Thus, NotifyVisitors will stop marking such devices as ‘uninstalled’ because this may incorrectly identify inactive users as churned, thereby inflating uninstall numbers.

Real-time Uninstall Tracking (Android)

  1. Kindly check whether the Android app is integrated with Firebase Analytics for real-time uninstall tracking. Add Firebase Analytics dependency in the app SDK. For more information, refer to the article titled ‘Get started with Google Analytics’.
  1. When a user uninstalls an app from their Android device, a Firebase event called ‘app_remove’ tracks the uninstall. You can push the aforementioned event to NotifyVisitors using the Firebase cloud functions.

Implement Real-time Uninstall Tracking

Real-time uninstall tracking is a three step process.

  1. Set up a Common Identifier.
  2. Set the ‘app_remove’ event as a conversion event in Firebase.
  3. Use the Firebase cloud function to send uninstall information to NotifyVisitors.

Set up a Common Identifier

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

private FirebaseAnalytics mFirebaseAnalytics;

mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
mFirebaseAnalytics.setUserProperty("nv_uid", NotifyVisitorsApi.getInstance(this).getNvUid());

Set up Conversion Event using Firebase

  1. To set up real-time uninstall, check that a conversion event is set up on the Firebase dashboard. Firebase analytics track an event called ‘app_remove’, which is one of the automatically collected Firebase events.
  1. The ‘app_remove’ event is an Android-only event that is tracked when an application package is removed or uninstalled from the device, irrespective of the installation source.

📘

Note

Firebase Blaze Plan Account Required

To allow Firebase cloud functions to call a third-party HTTP endpoint (NotifyVisitors API upload endpoint), a Firebase account with a Blaze plan is required. See Firebase Pricing for more information on pricing plans. Also ensure that the API region is configured correctly.

Perform the following steps to set up conversion:

  1. Select the Firebase project that is integrated with the Android app.
  2. Navigate to Analytics > Events in the Firebase Dashboard.
  3. Next, toggle 'ON' the Mark as conversion switch available for the ’app_remove‘ event.

Create a Cloud Function

  1. Once the conversion is set up, use the Cloud Function for Firebase to create a function that channels the app_remove data to NotifyVisitors.

Perform the undermentioned steps to create and publish a cloud function using Node JS:

  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 the option to use an existing project.
  7. Open index.js and add the following code:
'use strict';

const functions = require('firebase-functions');
const admin = require('firebase-admin');
const https = require('https');
var request = require('requestretry');


admin.initializeApp();
exports.NV_Android_App_Uninstall = functions.analytics.event('app_remove').onLog((event) => {

    const nvuid = (event.user && event.user.userProperties && event.user.userProperties.nv_uid) ? event.user.userProperties.nv_uid.value : '';
    const data = JSON.stringify({
       "nv": [{
            "nv_uid": nvuid,
            "event_name" : "uninstall",
            "ltv": "10"
        }]
    });

    request({
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'x-brand-id': 'NV_BRAND_ID', 
            'x-api-key': 'NV_API_KEY', 
        },
        body: data,
        url: 'https://analytics.notifyvisitors.com/api/v1/event/create'
    }, function (err, response, body) {
        if (response && response.statusCode === 200) {
            console.log("Response Body: " + JSON.stringify(body));
            return 0;
        }else{
            console.log("err: " + err + " ,response: " + JSON.stringify(response) + " , body: " + JSON.stringify(body));
            return 1;
        }
    });
});
  1. Replace <NV_BRAND_ID> and <NV_API_KEY> with your NotifyVisitors Brand ID and API Key in the index.js file. You can find these values in your dashboard.
  2. Open package.json and add the following code:
{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "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": {
    "firebase-admin": "^11.8.0",
    "firebase-functions": "^4.3.1",
    "web-push": "^3.4.4",
    "request": "^2.88.2",
    "requestretry": "^4.1.1"
  },
  "devDependencies": {
    "firebase-functions-test": "^3.1.0"
  },
  "private": true
}
  1. To deploy the cloud function for uninstall event listening, run the firebase deploy --only functions command.

📘

Note

For more information about deploying the Firebase Cloud Functions, refer to the Firebase Cloud Functions document.