gpt4 book ai didi

android - 如何从谷歌分析中获取推荐人/Activity 来源

转载 作者:太空宇宙 更新时间:2023-11-03 13:28:44 28 4
gpt4 key购买 nike

here的最底部开始.有一个 URL 生成器,我可以使用引荐来源网址在 Google Play 上生成指向我的应用程序的链接。我如何从谷歌分析中提取该 Activity 来源?我一直在谷歌上搜索,但仍然找不到答案。我发现有人说我应该创建一个扩展 BroadcastReceiver 的类,但我也发现了 here .这样一来,我将无法进行 GA 工作。 GA很强大,想用。我现在需要的是从 GA 中提取一个参数,该参数是推荐人/Activity 来源。我还发现 EasyTracker.getTracker() 下有几个 getter,比如 getAppId()、getAppInstallerId() 和 getTrackingId(),但都没有记录。我怎么知道哪个ID getter属于哪个?谢谢您的帮助!

最佳答案

虽然 referrer/campaign 教程文档在 GA(google analytics) 文档中,但您可以获取 Referrer 信息并在您的应用中使用它而无需实现 GA,请参阅:https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#google-play-implement

<!-- Used for Google Play Store Campaign Measurement-->
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

只需将第 3 行更改为您的自定义 BroadCastReceiver 示例:

<!-- Used for Google Play Store Campaign Measurement-->
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
<receiver android:name="com.xxx.Myapp.CustomReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

您的自定义 BroadCastReceiver 可能:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.google.analytics.tracking.android.CampaignTrackingReceiver;

/*
* A simple Broadcast Receiver to receive an INSTALL_REFERRER
* intent and pass it to other receivers, including
* the Google Analytics receiver.
*/
public class CustomReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

// get referrer info
String referrer = intent.getStringExtra("referrer");
// do anything you want with referrer
......

// When you're done, pass the intent to the Google Analytics receiver
new CampaignTrackingReceiver().onReceive(context, intent);
}
}

关于android - 如何从谷歌分析中获取推荐人/Activity 来源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16048815/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com