[Update]  The information in this post might be outdated. It worked at the moment of writing, but I don’t have the time to do a new research on the subject. I leave this post as is, it might work, or it might guide others to research the subject. Probably this feature still exists in some way.


Have you ever wondered if Android market sends you information at the moment of app install? Wouldn’t be nice to create custom links to your android application, including bits of information about the referrer, and send it directly to the app for processing at install? This could be a simple and accurate solution for mobile app install tracking but I’m sure you can find this useful in many ways…

With Android, you actually get this information as a broadcasted intent by android market at install time – even before opening your app.

I recently had to deal with Android app tracking. There are numerous ad networks you can join which offer mobile app tracking but depending on the method used, download and install tracking is not always easy, or not 100% accurate, not to speak about determining the referer which has led to a conversion(install).

I’ll talk more about mobile app tracking in other posts. For now, let’s focus  on the solution for the above problem.

Remember, we are talking only about Android devices. Official Android documentation describes this subject more or less as Google Analytics use this method.

I will assume you have some knowledge about Android development, especially broadcast intents and broadcast receivers. Here are the steps for getting the referer:

  • As you may know, url scheme for opening Android Market app and viewing, for example the app my.package.appname is as follows:


  • You can append, among others, a referrer parameter to this link, having any url encoded string as a value. For example, for the value “this is the referrer”:


  • When this app is installed from Android market, the second sends a broadcasted intent with the action “com.android.vending.INSTALL_REFERRER
  • In order to get this intent we will build a class which extends BroadcastReceiver.
public class ReferrerCatcher extends BroadcastReceiver {

 private static String referrer = "";

 public void onReceive(Context context, Intent intent) {

  • In the onReceive method, you can get the referrer param by extracting the information from the received intent:

public void onReceive(Context context, Intent intent) {
   referrer = "";
   Bundle extras = intent.getExtras();
   if(extras != null){
      referrer = extras.getString("referrer");


   Log.w("REFERRER","Referer is: "+referrer);

  • The last thing you want to do is register this BroadcastReceiver in your manifest file with the specified intent filter. This should go between application tags!!!

<receiver android:name="my.package.ReferrerCatcher"
   <action android:name="com.android.vending.INSTALL_REFERRER"></action>

A few notes about this:

  1. As broadcast receivers work on the main thread don’t  do lengthy processing here. As a matter of fact, the rule says no longer than 5 seconds of processing here, otherwise a force close dialog will appear.
  2. You can create a background thread in the onReceive method for processing lengthy tasks like sending referrer to a server.
  3. If  you use more broadcast receivers for INSTALL_REFERRER action(like Google Analytics) make sure they don’t block each other. Take a look at this article where I give a solution about this.