Search code examples
androidreferrals

Android Install referral tracking uniqueness


I implemented install referral tracking in my app from: https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#google-play-campaigns

my referral receiver:

    public class ReferrerReceiver extends BroadcastReceiver
{
    private static final ObservableChanged _observable = new ObservableChanged();

    //--------------------------------------------------------------------------
    public static Observable getObservable()
    {
        return _observable;
    }

    //--------------------------------------------------------------------------
    public static String getReferrer(Context context)
    {
        // Return any persisted referrer value or null if we don't have a referrer.
        return context.getSharedPreferences("referrer", Context.MODE_PRIVATE).getString("referrer", null);
    }

    //--------------------------------------------------------------------------
    public ReferrerReceiver()
    {
        Logger.log(null, "ReferrerReceiver.ReferrerReceiver()");
    }

    //--------------------------------------------------------------------------
    @Override public void onReceive(Context context, Intent intent)
    {
        Logger.log(context, "ReferrerReceiver.onReceive(Context, Intent)", intent);

        try
        {
            // Make sure this is the intent we expect - it always should be.
            if ((null != intent) && (intent.getAction().equals("com.android.vending.INSTALL_REFERRER")))
            {
                // This intent should have a referrer string attached to it.
                String rawReferrer = intent.getStringExtra("referrer");
                if (null != rawReferrer)
                {
                    // The string is usually URL Encoded, so we need to decode it.
                    String referrer = URLDecoder.decode(rawReferrer, "UTF-8");

                    // Log the referrer string.
                    Logger.log(context,
                        "ReferrerReceiver.onReceive(Context, Intent)" +
                        "\nRaw referrer: " + rawReferrer +
                        "\nReferrer: " + referrer);

                    // Persist the referrer string.
                    context.getSharedPreferences("referrer", Context.MODE_PRIVATE).
                        edit().putString("referrer", referrer).commit();

                    // Let any listeners know about the change.
                    _observable.notifyObservers(referrer);
                }
            }
        }
        catch (Exception e)
        {
            Logger.log(context, e.toString());
        }
    }

    //**************************************************************************
    protected static class ObservableChanged extends Observable
    {
        //----------------------------------------------------------------------
        @Override public boolean hasChanged()
        {
            return true;
        }
    }
}

but referrer attribute is getting broadcasted by the Play Store to my app after every repeated install(uninstall and install on same device).

for a quick test install this app from play store(not mine) from this link: https://play.google.com/store/apps/details?id=fr.simon.marquis.installreferrer&referrer=myReferrerValue

you will get referral value = "myReferrerValue" on every first launch of repeated install(uninstall and install on same device).

My questions are:

  1. Does the play store send referral broadcast even when app are installed on the same device repeated times?

  2. Shouldn't referrers only be broadcasted once per device?


Solution

    1. Yes the play store will send the referrer every time the app is installed using a link that contains parameters.

    2. If you care about uniqueness, you need some backend to verify that yourself. This is how e.g adjust does it. The referrer is stored in the Receiver and sent to a backend at some point in the future.

    If you think of it it makes a lot of sense: The only thing that the Play Store App does is taking the referrer parameters from the url and delegating it back to the installed app. There is basically no logic involved here.

    Also, the developers at google don't know whether you are interested in the uniqueness or not, so they will not prevent you from counting installs multiple times, if you want. (AFAIK the statistics panel in the Play Developer Console does filter out duplicates, but they're still delivered to your app)