Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get referrer after installing app from Android Market

I am trying to register a Broadcast Receiver that catches "com.android.vending.INSTALL_REFERRER" intents launched by Android after an app is installed from the Market.

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

However, I cannot use Google Analytics so I have created my own solution. I have added the following to my 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 a basic BroadcastReceiver class:

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 app is installed the receiver doesn't seem to catch the Intent (if the Intent is even broadcast?) and I get no logging output.

Am I going wrong somewhere or is the Market no longer launching these Intents when an app is installed?

like image 211
Jake Avatar asked Nov 04 '10 01:11

Jake


People also ask

What is install referrer Android?

The definition of install referrer An Install Referrer is an Android-specific ad tracking identifier. Like Device IDs and Device Fingerprinting, an install referrer is a unique string that's sent to the Play Store when a user clicks on an ad.

How do I do a test install referrer?

If all goes well, you should be able click the generated URL on your Android device, go to the Play store, install the "Referrer Test for Google Play" application, run the application, and see the referrer string you entered on this site show up in the log within the application.

How does Google install referrer work?

The Google Install Referrer is an Android-specific measurement technology that attributes clicks on Google Play Store app pages to the correlating app download. Google's Install Referrer framework sends an install referrer (or unique code string) to the Google Play store when an ad click has occurred.

Is Play install referrer API permission safe?

You can use the Google Play Store's Install Referrer API to securely retrieve referral content from Google Play, such as: The referrer URL of the installed package. The timestamp, in seconds, of when a referrer click happened (both client- and server-side).


2 Answers

I would try to help who, like me, fails to make install_referrer work and who don't find ANY useful information about these features.

Notes:

  1. The intent com.android.vending.INSTALL_REFERRER will be caught during the install process, not when the application starts for the first time.
  2. The referrer ...extras.getString("referrer").. is fixed but the contents can be any string value that respect the http get syntax ...referrer=thatsthevalue&thisisnot=xxx

The above code is okay, just some explanations to complete the info:

  1. Android Manifest. The <receiver> tags must be inside the <application> tags.
  2. The correct url to link the market is not the results 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 the mobile device and the only way for a complete test is to publish a test application in the market.

And a final and personal note.

I don't understand why those info are omitted completely and i hope that Google will act for detailing it.

like image 69
Tobia Avatar answered Sep 18 '22 10:09

Tobia


This might be a little late, but you CAN test the install referrer without using Google Play, just use ADB :)

Run this 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 logging setup in your BroadcastReceiver, you will see it popup in LogCat.

Hope this helps!

like image 20
Machine Tribe Avatar answered Sep 22 '22 10:09

Machine Tribe