本文主要是介绍GooglePlay渠道跟踪 INSTALL_REFERRER,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
原理
点击带有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 {@Overridepublic 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中添加
<receiverandroid: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的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!