Installation Event Tracking
Track App Installs and App Updates
1. Track App Install and Update event by Netcore
To allow CEE SDK to track the app install and update event, you just need to call the below method so we will track the app install and update event on behalf of you.
We will consider the app is updated whenever the version code inside the app is greater than the previous version code.
Smartech.getInstance(new WeakReference<>(context)).trackAppInstallUpdateBySmartech();
Smartech.getInstance(WeakReference(context)).trackAppInstallUpdateBySmartech()
SmartechSDK.trackAppInstallUpdateBySmartech()
2. Track App Install & App Update Manually
If you have your own logic to identify if its first app launch, you can use the below step to trigger the App Install Event.
Smartech.getInstance(new WeakReference<>(context)).trackAppInstall();
//Sample code
boolean isFirstLaunch=sharedPreferences.getBoolean("is_first_launch",true);
if(isFirstLaunch){
Smartech.getInstance(new WeakReference<>(context)).trackAppInstall();
sharedPreferences.putBoolean("is_first_launch",false);
}
Smartech.getInstance(WeakReference(context)).trackAppInstall()
//Sample code
val isFirstLaunch = sharedPreferences.getBoolean("is_first_launch", true)
if (isFirstLaunch) {
Smartech.getInstance(WeakReference(context)).trackAppInstall()
sharedPreferences.putBoolean("is_first_launch", false)
}
SmartechSDK.trackAppInstall()
If you have your own logic to track whether the user has updated the app version, you can use the below step to trigger the App Update Event.
Smartech.getInstance(new WeakReference<>(context)).trackAppUpdate();
//Sample code
String currentVersion = BuildConfig.VERSION_NAME;
String preferenceVersion = sharedPreferences.getString("app_version", "");
if (!preferenceVersion.isEmpty()) {
if (!currentVersion.equals(preferenceVersion)) {
Smartech.getInstance(new WeakReference<>(context)).trackAppUpdate();
sharedPreferences.putString("app_version", currentVersion);
}
} else {
sharedPreferences.putString("app_version", currentVersion);
}
Smartech.getInstance(WeakReference(context)).trackAppUpdate()
//Sample code
val currentVersion = BuildConfig.VERSION_NAME
val preferenceVersion = sharedPreferences.getString("app_version", "")
if (!preferenceVersion.isEmpty()) {
if (currentVersion != preferenceVersion) {
Smartech.getInstance(WeakReference(context)).trackAppUpdate()
sharedPreferences.putString("app_version", currentVersion)
}
} else {
sharedPreferences.putString("app_version", currentVersion)
}
SmartechSDK.trackAppUpdate()
Tracking the Re-Installs
Step1: Creating the full backup content file.
Create an XML file in the xml directory of your resources (i.e. res/xml/my_backup_file). Copy the below snippet in the XML file.
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<include domain="sharedpref" path="smt_guid_preferences.xml"/>
<include domain="sharedpref" path="smt_preferences_guid.xml"/>
</full-backup-content>
Android 12 or higher
If your app targets Android 12 (API level 31) or higher, Create an XML file in the xml directory of your resources (i.e. res/xml/my_backup_file_31). Copy the below snippet in the XML file.
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
<cloud-backup disableIfNoEncryptionCapabilities="false">
<include domain="sharedpref" path="smt_guid_preferences.xml" />
<include domain="sharedpref" path="smt_preferences_guid.xml" />
</cloud-backup>
</data-extraction-rules>
Step2: Update the application to allow backup.
Add allowBackup
, fullBackupContent
and 'dataExtractionRules' tags in the application tag of your AndroidManifest.xml.
<application
android:name=".MyApplication"
android:allowBackup="true"
android:fullBackupContent="@xml/my_backup_file"
//If your app targets Android 12 (API level 31) or higher add the below line
android:dataExtractionRules="@xml/my_backup_file_31"
...
/>
NOTE:
- Re-Installs works for users with Android OS version 6.0 and higher.
- The user must be logged in to his Google account and must have enabled backup and restore in order to track re-install. (and have at least 25MB space available in Google drive)
Click here to explore predefined events in CEE
Updated 4 months ago