Android收藏集

GooglePlay渠道跟踪 INSTALL_REFERRER

2019-02-26  本文已影响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)

上一篇下一篇

猜你喜欢

热点阅读