What is 'action android:name="com.android.vending.INSTALL_REFERRER" '?

netcleaner picture netcleaner · Sep 29, 2012 · Viewed 10.4k times · Source

I had tested the Appbrain SDK and Inmobi SDK. And I found this common receiver. And I made custom receiver. I thought that when download the app in google market, google market sends 'referer' value to my app. But I haven't received anything. What's problem?

//This is Appbrain's receiver
<receiver android:exported="true" android:name="com.appbrain.ReferrerReceiver" >
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>


//This is Inmobi's receiver
<receiver android:name="com.inmobi.adtracker.androidsdk.IMAdTrackerInstallRefererReciever" android:exported="true"  >
   <intent-filter>
      <action android:name="com.android.vending.INSTALL_REFERRER" />
      <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
   </intent-filter>
</receiver>


//This is My Custom receiver
<receiver android:name="com.xgame.adproject2.TestReceiver" android:exported="true" >
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

// source
public class TestReceiver extends BroadcastReceiver{

    public static final String TAG = "TEST";

    String referrerString = "";

    @Override
    public final void onReceive(Context context, Intent intent) {

        Log.e(TAG, "11111111");

        if(intent.getAction().equals("com.android.vending.INSTALL_REFERRER")) {
           Bundle extras = intent.getExtras();
           referrerString = extras.getString("referrer");

           Log.e(TAG, "REFERRER: " + referrerString);
        }
    }
}

When down the app, I was input this url in android web browser. But after download app, I haven't received referrer value.

https://play.google.com/store/apps/details?id=com.xgame.adproject2&referrer=utm_source%3Dcom.xgame.adproject2%26utm_medium%3Dgoogle%26utm_term%3Dbanner%26utm_campaign%3Dxgame

Answer

Mathijs Vogelzang picture Mathijs Vogelzang · Oct 1, 2012

One important thing to note is that the Android market / Google Play will only send the install referrer to the first receiver you define in your manifest. So in this case only the AppLift receiver will get it.

There is a way to "forward" the event from the AppLift receiver as described in the JavaDoc: http://swisscodemonkeys.github.com/appbrain-sdk/javadoc/reference/com/appbrain/ReferrerReceiver.html

In your case, your manifest should look like this:

//This is Appbrain's receiver
<receiver android:exported="true" android:name="com.appbrain.ReferrerReceiver" >
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
    <meta-data android:name="forward.inmobi" android:value="com.inmobi.adtracker.androidsdk.IMAdTrackerInstallRefererReciever" /> 
    <meta-data android:name="forward.custom" android:value="com.xgame.adproject2.TestReceiver" />
</receiver>

// Keep the execution of InMobi on connectivity change
<receiver android:name="com.inmobi.adtracker.androidsdk.IMAdTrackerInstallRefererReciever" android:exported="true" >
   <intent-filter>
      <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
   </intent-filter>
</receiver>

Note that a related bug on the Android issue tracker that might be worth starring is this: http://code.google.com/p/android/issues/detail?id=24119 (it's about bringing back referrer strings from organic app discovery, and if they fix that hopefully they will also add the referrer string when an install comes through the Play website).