-1

I am trying to get the referrer details from the URL when the app is downloaded via marketing URL. I have created a broadcast receiver with INSTALL_REFERRER intent filter.

My URL is: http://hrt.glserv.info/com.cc.rummycentral?referrer=ewriewriwer&pid=vcommission_rummytest&af_r=http%3A%2F%2Frc.glserv.info%2Fdownload-apk%2F

// my Manifest code for receiver

 <receiver android:name="com.cc.rummycentral.service.DownloadReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER"></action>
            </intent-filter>
        </receiver>

DownloadReceiver class:

public class DownloadReceiver extends BroadcastReceiver
{
    private static String TAG = "referrer";

    public DownloadReceiver(){
        Log.w(TAG, "INSIDE DownloadReceiver()");
    }

    @Override
    public void onReceive(Context context, Intent intent)
    {
        try
        {
            Log.w(TAG, "INSIDE onReceive");
            if (null != intent && intent.getAction().equals("com.android.vending.INSTALL_REFERRER"))
            {
                Log.w(TAG, "YES, IT IS AN INSTALL EVENT");
                String rawReferrer = intent.getStringExtra("referrer");
                if (rawReferrer != null) {
                    String referrer = URLDecoder.decode(rawReferrer, "UTF-8");
                    Log.w(TAG,"HEY Received Referrer: " + referrer);
                }
            }
        } catch (Exception var6) {
            var6.printStackTrace();
            Log.e(TAG, "EXP: "+var6.toString());
        }
    }
}

2 Answers2

0

You have to install the app via playstore in order for this broadcast to work, Referrer broadcast is not a system broadcast, it is sent by playstore when an app is installed via playstore

Suhaib Roomy
  • 2,501
  • 1
  • 16
  • 22
  • Is there any other way to track the referrer details? In my case, the app will be downloaded from a third-party website directly. – Nikhil Sharma May 23 '18 at 12:02
  • you can make separate apks for different referrers, thats the only way i guess. All other third party sdks like branch/firebase require app to be downloaded by playstore – Suhaib Roomy May 23 '18 at 12:19
  • How can I make an App listen to a specific referrer? Can you share a sample code snippet for the same? – Nikhil Sharma May 23 '18 at 12:33
  • In case you want to make separate apks, your broadcast listener will not work, since there are no broadcasts to be received, what I meant was you can hardcode the referrer in the java code for different APKs, I know it is not an elegant solution but i don't think there is any alternate solution – Suhaib Roomy May 23 '18 at 12:36
  • The reason that there is no other solution is that you will only get to know about the install if the installer notifies you, for third party install android system installs the app and there would be no broadcasts about referrer from android system – Suhaib Roomy May 23 '18 at 12:37
  • I wanted to track the unique click ID for every install, hence cannot hardcode the value. AppsFlyer and TUNE track these without hardcoding any value in the app. I was trying to achieve the same result here. – Nikhil Sharma May 23 '18 at 12:40
  • These sdk must be either using playstore, or once the user clicks on install, they would be gathering some uniquely identifiable information of the device and after the install would match the same information sent from app to track an install. If you can collect unique ID such as GAID, then you can also impelement the same thing on your server – Suhaib Roomy May 23 '18 at 12:55
0

There is a solution to make this scenario work. Make sure the app is downloaded from play store link . And generate the play store url from your third party website with referral id and website details and redirect to play store . This makes it works

Jinson Paul
  • 481
  • 6
  • 17