How Android app install tracking works?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 21:30:44

问题


can anybody here explain how android app referral tracking works? a friend gave me an android app's google play referral url. And i installed the app and opened it. How does the app developer know that it's my friend who referred me to their app? I know that the link that my friend gave me contains his referral details but if i close google play after completing the app install, how can google play detect that i opened the app? So some unique data is injected into the app while i install it from playstore. am i right? Please explain.


回答1:


It's quite simple actually. You click on the link with a referral (Google calls them Campaing Attribution) and this link is passed to the Google Play Store app. Then, when you install the app, the Play Store also forwards this data (campaign name, source, &c) to the app itself.

The app just needs to have a particular BroadcastReceiver (with an intent-filter for the com.android.vending.INSTALL_REFERRER action) declared in its Manifest for this to work.

It's well explained in the Google Play Campaign Attribution section of the Google Analytics documentation.




回答2:


Here is an example how you can implement a custom BroadcastReceiver with INSTALL_REFERRER.

AndroidManifest.xml

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

ManyInstallTrackersReceiver.java

import com.google.android.gms.tagmanager.InstallReferrerReceiver;

public class CustomInstallTrackersReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        try {
            // Implementing Google Referrer tracker
            InstallReferrerReceiver googleReferrerTracking = new InstallReferrerReceiver();
            googleReferrerTracking.onReceive(context, intent);

            // Do something with referrer data to do your own tracker.
            Log.d("CustomInstallTrackers", "Referrer: "+intent.getStringExtra("referrer"));
        } catch(Exception e){
            e.printStackTrace();
        }
    }
}

You can test it with the following commands

$ adb shell
$ am broadcast -a com.android.vending.INSTALL_REFERRER -n com.your.package/com.your.package.CustomInstallTrackersReceiver --es "referrer" "hello%3Dworld%26utm_source%3Dshell"



回答3:


From 20 November 2017, Its very simple using Google Play Referrer API



来源:https://stackoverflow.com/questions/24226895/how-android-app-install-tracking-works

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!