2

I've found some solutions to track referrer URL from the market, but my apps aren't in the market.

Is there a way to get the referrer URL for applications downloaded from private sites?

elgorje
  • 31
  • 3
  • Hello there. Did you find any way to do that? I have same question here: http://stackoverflow.com/questions/41740766/how-to-broadcast-referral-to-android-app – Hossein Shahsahebi Jan 21 '17 at 08:30

1 Answers1

0

To get referrer, you need to register your receiver for that. After installation, a broadcast is fired which you need to catch by following code.

First take a look at Android Native Application Tracking Overview

1. Create a Receiver

public class ReferrerReceiver extends BroadcastReceiver {

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

        Bundle extras = intent.getExtras();
        String referrerString = extras.getString("referrer");

        Log.i("Home", "Referrer is: " + referrerString);
    }
}

2. Register in Manifest file

<receiver android:name="your.package.name.ReferrerReceiver" android:exported="true">
<intent-filter>
    <action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Chintan Rathod
  • 25,864
  • 13
  • 83
  • 93
  • Thanks for your answer, but I can't get it to work. I've added the google analytics lib to the build path, used the receiver code as an inner class of my activity, so I can use referrerString and declared it in the manifest like this android:name=mypackname.app1.MainActivity$ReferrerReceiver. I've signed and uploaded the apk to my server, but after installing it I haven't been able to get the URL – elgorje Sep 02 '13 at 15:54