我注意到浏览器中的一些Google Play应用程序链接具有referrer=属性,这显然会告诉推荐人,它会将您发送到Google Play中该应用程序的页面。
是否可以在我的应用程序的代码中看到引用(如果有的话)?如果不是,在任何地方都能看到它吗?
发布于 2015-05-15 16:45:26
您可以使用com.android.vending.INSTALL_REFERRER。
当从
Play商店安装应用程序时,会广播Google Play com.android.vending.INSTALL_REFERRER意图。
将此接收器添加到AndroidManifest.xml
<receiver
android:name="com.example.android.InstallReferrerReceiver"
android:exported="true"
android:permission="android.permission.INSTALL_PACKAGES">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>创建BroadcastReceiver:
public class InstallReferrerReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String referrer = intent.getStringExtra("referrer");
//Use the referrer
}
}您可以按照此answer的步骤测试推荐跟踪。
发布于 2018-04-20 17:54:48
使用Google Play Referrer API (2017年11月20日起)
InstallReferrerClient mReferrerClient
...
mReferrerClient = newBuilder(this).build();
mReferrerClient.startConnection(this);
@Override
public void onInstallReferrerSetupFinished(int responseCode) {
switch (responseCode) {
case InstallReferrerResponse.OK:
try {
ReferrerDetails response = mReferrerClient.getInstallReferrer();
String referrer = response.getInstallReferrer()
mReferrerClient.endConnection();
} catch (RemoteException e) {
e.printStackTrace();
}
break;
case InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
Log.w(TAG, "InstallReferrer not supported");
break;
case InstallReferrerResponse.SERVICE_UNAVAILABLE:
Log.w(TAG, "Unable to connect to the service");
break;
default:
Log.w(TAG, "responseCode not found.");
}
}发布于 2015-05-07 22:21:37
Campaign Parameters用于将活动或流量来源的信息传递到应用程序的谷歌分析实现中,这些信息将用户引向应用程序的谷歌Play商店页面。
构建好活动参数字符串后,将其作为referrer参数的值添加到Google Play Store URL中,如下例所示:
https://play.google.com/store/apps/details?id=com.example.app
&referrer=utm_source%3Dgoogle
%26utm_medium%3Dcpc
%26utm_term%3Drunning%252Bshoes
%26utm_content%3DdisplayAd1
%26utm_campaign%3Dshoe%252BcampaignGoogle Play Store会将referrer参数的值传递给应用程序的Google Analytics实现。
参考资料:https://developers.google.com/analytics/devguides/collection/android/v2/campaigns https://developers.google.com/analytics/devguides/collection/android/v2/campaigns#google-play-url-builder
https://stackoverflow.com/questions/30103338
复制相似问题