Search code examples
androidapkuser-tracking

Track android apk download source(not from Google play)


i wan't to track my app download source,apk will be available through several campaigns. Issue is app download link is direct url, It is not on Google Play Store so i can't receive INSTALL_REFERER broadcast.

I can track clicks easily by logging each click on my server, but how to track user installed and run app (and download source)

Approch 1:

  • Run one java script for each campaign URL, get some device specific info, send to server
  • Now when user installs and run that app, run same java script, capture and send info
  • if same info record matches with some previous record we know app download was successful

Problem in above approach is i am not able to narrow down what all info i should capture in javascript to identify the user, keeping in mind different android browsers available and android device fragmentation.


Solution

  • got this one working, with the help of aapt.

    Basic approach is to insert a file in assets in apk on the fly.

    requires:

    • a web-server able to serve apk e.g. apache, add mime types for apk in web-server config files.
    • a server side script which can execute shell commands e.g. php, jsp
    • an unsigned-apk, unsigned coz aapt seems to have some problem with modification of signed apks and then again resigning them.
    • android and java sdk on serving machine

    then:

    As soon as user clicks on the download link hosted on your web-site, record an entry in a db, with some field describing the state as downloaded/downloading.

    generate your text property file to be inserted inside assets folder in apk. use aapt to add it to apk.

    aapt remove app.apk "assets/tracker.txt"

    aapt add app.apk "assets/tracker.txt"

    directory structure where source apk will be hosted like this : ROOT-> (assets ->(app_tracker.txt)) + app.apk

    after this signing

    jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -storepass STORE_PASSWORD -keystore KEYSOTRE_PATH alias_name

    NOTE: you should not modify the source app.apk and tracker.txt, what you should is to copy it to some relative path and then do modification over it.

    hope it helps, it helped me though :)