Get referrer after installing the application from Android Market

I am trying to register a broadcast receiver that catches the intent of "com.android.vending.INSTALL_REFERRER" launched by Android after the application is installed from the market.

I read the details here: http://code.google.com/mobile/analytics/docs/android/#referrals

However, I cannot use Google Analytics, so I created my own solution. I added the following to the manifest file:

<receiver android:name="com.test.Receiver" android:exported="true"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> 

and created the base class BroadcastReceiver:

 public class Receiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); String referrerString = extras.getString("referrer"); Log.w("TEST", "Referrer is: " + referrerString); } } 

However, when the application is installed, the receiver does not seem to catch the intent (if the Intent even broadcasts?), And I do not get the log output.

How am I wrong somewhere or does the market no longer launch these intentions when the application is installed?

+63
android install referrer google-play-services google-play
Nov 04 '10 at 1:28
source share
7 answers

I would try to help those who, like me, could not do install_referrer work and who did not find ANY useful information about these functions.

Notes:

  • The intentional intent is com.android.vending.INSTALL_REFERRER during the installation process, and not when starting the application for the first time.
  • Referrer ... extras.getString("referrer") .. fixed, but the content can be any string value that matches the syntax http get ... referrer=thatsthevalue&thisisnot=xxx

The above code is fine, just some explanation to populate the information:

  • Android Manifest. The <receiver> tags must be inside the <application> .
  • The correct URL for a market link is not the result of the famous google forms in sdk

but this one

http://market.android.com/details?id=your.application.package.name&referrer=my_referrer_finally_works_fine

Obviously, you need to follow the link from a mobile device, and the only way to complete the test is to publish the test application on the market.

And the last and personal note.

I don’t understand why this information is completely omitted, and I hope that Google will act to detail it.

+45
Dec 14 '10 at 13:16
source share
β€” -

It may be a little late, but you can test the installation link without using Google Play, just use ADB :)

Run it from adb.exe

 adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n your.package/path.to.your.BroadcastReceiver --es "referrer" "test_referrer=test" 

If you have a logging setting in your BroadcastReceiver, you will see its popup in LogCat.

Hope this helps!

+16
Jun 09 '15 at 13:18
source share

Ok, so I found the reason the intention did not start. Obviously, you SHOULD use the same parameter names as here: http://code.google.com/mobile/analytics/docs/android/#referrals

You cannot use your own parameter names, as I did: S

+5
Nov 04 '10 at 1:43
source share

I think these answers should have been written before Android 3.1 - because everything changed in one way of importing.

The system now notes that the application is inactive when they are installed - they will not receive INSTALL_REFERRER or any other broadcast until the user explicitly activates the application by launching it (or placing the widget).

+5
Sep 13 '12 at 15:57
source share

I agree that the Google documentation is not the best. However, I was only able to get the intention to launch by downloading the application on Market Place, and then downloading / installing it. The target starts immediately after downloading / installing - the user does not need to run the application. I use this to start a background service.

+2
Mar 28 2018-11-21T00:
source share

Please note that this is not the first intention to start, but only the Android market intention of my google Android portal. If you install the application through a different resource than the Android market, it does not work.

Use the link that you can build there: http://code.google.com/mobile/analytics/docs/android/#android-market-tracking get the referrer from the intent and split it to get different parameters

 referrer = intent.getStringExtra("referrer"); Map<String, String> params = Toolbox.getQueryMap(referrer); 

PS You do not need to read to read deviceid / IMEI to do this, as some applications do. You do not have to track your users.

+2
Jun 15 '11 at 18:53
source share

In fact, there may be any links, such as market: // ... or http: // market .... It also does not matter what parameters will be in the referrer field. It works great with any text there.

The main problem is that this type of event, "com.android.vending.INSTALL_REFERRER", is not being broadcast. This event goes ONLY to the newly installed application.

UPD: And there is only one way to test it - deploy the application to the market and then install it on the phone.

+1
May 03 '11 at 5:52 a.m.
source share



All Articles