美文网首页Android收藏集
GooglePlay渠道跟踪 INSTALL_REFERRER

GooglePlay渠道跟踪 INSTALL_REFERRER

作者: 食不知味_夜不能寐 | 来源:发表于2019-02-26 20:30 被阅读2次

    参考:Android集成

    原理

    点击带有referrer的链接(形如http://xxxx&referrer=test%3Dtest111)跳转到Google Play后,Google Play会记录(Capture)附带的参数,下载安装后(经测试,必须从Play商店点击下载并安装才可行),首次打开APP时,Gooogle Play会将参数广播(Deliver)给APP。

    流程

    点击带有referrer的链接(形如http://xxxx&referrer=test%3Dtest111)>>跳转到google play(Capture referrer for com.xxx.xxx )>>下载完成>>打开app(Delivered referrer for com.xxx.xxx

    配置

    新建一个继承自BroadcastReceiver的类,用于接收referrer

    public class InstallReferrerReceiver extends BroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            String referrer = intent.getStringExtra("referrer");
    
            Log.e("zqj", "install referrer:" + referrer);
            if(referrer != null && referrer.length() > 0){
                Log.e("zqj", "install referrer:" + referrer);
                return;
            }
        }
    }
    

    再在AndroidManifest中添加

            <receiver
                android:name="com.xxx.xxx.InstallReferrerReceiver"
                android:exported="true"
                android:permission="android.permission.INSTALL_PACKAGES" >
                <intent-filter>
                    <action android:name="com.android.vending.INSTALL_REFERRER" />
                </intent-filter>
            </receiver>
    

    几种情况:

    1.没有安装app,通过http://xxxx&referrer=test%3Dtest111跳转到Google Play,可以正常Capture referrer,安装app,打开app,可以正常deliver referrer: test=test111
    2.没有安装app,通过http://xxxx&referrer=test%3Dtest111跳转到Google Play,再通过http://xxxx&referrer=test%3Dtest222跳转google play,安装app,打开app,deliver referrer: test=test222
    3.没有安装app,通过http://xxxx&referrer=test%3Dtest111跳转到Google Play,安装app,再通过http://xxxx&referrer=test%3Dtest222跳转google play,无法再次Capture referrer(Dropped referrer for com.peoplefun.wordcross because dropped_already_captured),打开app,可以正常deliver referrer: test=test111
    4.已经安装app,通过http://xxxx&referrer=test%3Dtest111跳转到Google Play,无法Capture referrer(Dropped referrer for com.peoplefun.wordcross because dropped_already_installed)

    相关文章

      网友评论

        本文标题:GooglePlay渠道跟踪 INSTALL_REFERRER

        本文链接:https://www.haomeiwen.com/subject/vbuayqtx.html