Android Attribution for Pre-Installed Apps


AppsFlyer's pre-install feature enables advertisers to track metrics for apps which are installed on an Android device at the time of purchase.

When an app is launched it is listed in the AppsFlyer's dashboard under a custom media source (as shown in the example below) with the campaign labeled as preinstall.  

Pre-Installed App Tracking

There are three methods for tracking pre-installed apps:

Path Method

From version 4.5.0 and above of the AppsFlyer Android SDK, you can configure the /data/local/tmp/pre_install.appsflyer path in the manifest to allow the AppsFlyer SDK to track pre-installs.

<meta-data android:name="AF_PRE_INSTALL_PATH" android:value="/data/local/tmp/pre_install.appsflyer" />

The file to which the path points to should contain a key and a value - the key is the package name and the value is the origin of the app (e.g. Amazon).  An example of the format of the file is as follows:




Read, write and execute file permissions for the pre_install.appsflyer file must be set to 7 on the third triad (group), for example 447 (-r--r--rwx).

System Properties Method

This method is supported from SDK version 4.4.0.

Android property system maintains key-value pairs that manage system configuration and can be used for start/stop services (daemon process).  

For example: wpa_supplicant, dhcpcd etc.

You can also use it to check the status of the services and other system parameters.  In addition, it can be used as an IPC mechanism, although it may not be very effective as it takes time for changes to be reflected.

Accessing Properties

Android provides three methods to access properties:

  • Native code (cutils/properties.h)
  • Java code (android.os.SystemProperties) that eventually calls the native code library
  • Shell (getprop/setprop). Click here to read more in detail.

The Android property system is initialized by an init process which loads properties from:

/default.prop, /system/build.prop, /system/default.prop, /data/local.prop files.


Not all of the files might be present on the actual device, though build.prop is always present, as it contains system properties.

Adding a Key-Value Pair to Android System Properties

To add a key-value pair to Android System Properties:

[Root is needed] Run these shell commands:

> adb shell su
> setprop ro.appsflyer.preinstall.path=/data/pre_install.appsflyer

A similar method is to retrieve the system-properties-file from the android file system, edit it, and push it back:

> adb root
> adb remount
> adb pull /system/build.prop
> echo ro.appsflyer.preinstall.path=/data/pre_install.appsflyer >> build.prop
> adb push build.prop /system/build.prop
> adb shell chmod 644 /system/build.prop
> adb reboot

Alternatively, if you are building an Android Open-Source Project:

- build.prop is an autogenerated file generated by script present in "{AOSP root}/build/tools". 
- Add your key-value pair at the end. Ex - "ro.appsflyer.preinstall.path=/data/pre_install.appsflyer". Here key is "ro.appsflyer.preinstall.path" and value is "/data/pre_install.appsflyer".
- Now do a build and flash system.img to your phone.
- Reboot and login to phone shell (adb shell su) and type "getprop ro.appsflyer.preinstall.path" to verify.
- Note, you need to be root in order to be able to change property (setprop) or execute your program/command as root.

SDK API Method

This method is supported from SDK version 4.8.10.

The following API needs to be called before SDK initialization:

setPreinstallAttribution(String mediaSource, String campaign, String siteId)

mediaSource is mandatory.

campaign and siteId are optional

media source , campaign and site id should be lower case and are enforced by the SDK.

For details of how to Tracking Installs for Out-Of-Store, click here.

Was this article helpful?
2 out of 3 found this helpful