【发布时间】:2020-02-07 07:39:30
【问题描述】:
据我的老板说,我们的一些应用程序已投资于通过 Google Ads 为应用程序做广告。为了让他们解析数据并正确分析它们,他们正在使用 UTM 自动标记方法。客户端(Android 设备)的工作是使用 Firebase Analytics 发送 UTM,并根据此 UTM 向 Firebase 发送自定义事件。
但是,我们的数据显示 Firebase SDK 和我们的事件都未正确传输。点击次数和下载次数不匹配。由于两者都不正确,我猜测设备本身接收到的 UTM 是错误的,需要正确接收,我无法找到答案。
我正在使用Install Referrer Library 来追踪应用程序下载到设备后的 UTM 是什么。我猜 Firebase SDK 也使用了一些类似的方法。我们这边把UTM记录到SharedPreferences,查询成功就不再查询。
下面是它的相关代码(processReferrer方法基本上是根据我们的需要解析UTM):
/**
* Checks if the referrer information is recorded before, if not, creates
* a connection to Google Play and saves the data to shared preferences.
*/
private static void fetchReferrerInformation(Context context)
{
SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(context);
String utmData = preferences.getString(UTM_DATA, "");
// Only connect if utm is not recorded before.
if (TextUtils.isEmpty(utmData))
{
InstallReferrerClient client;
try
{
client = InstallReferrerClient.newBuilder(context).build();
client.startConnection(new InstallReferrerStateListener()
{
@Override
public void onInstallReferrerSetupFinished(int responseCode)
{
switch (responseCode)
{
case InstallReferrerClient.InstallReferrerResponse.OK:
{
ReferrerDetails response;
try
{
response = client.getInstallReferrer();
}
catch (Exception e)
{
Log.e(TAG, "Error while fetching referrer information.", e);
if (Fabric.isInitialized())
Crashlytics.logException(new IllegalStateException("Exception while fetching UTM information.", e));
return;
}
if (response != null)
{
processReferrer(context, response.getInstallReferrer());
}
break;
}
case InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
{
Log.w(TAG, "Install referrer client: Feature is not supported.");
break;
}
case InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE:
{
Log.w(TAG, "Install referrer client: Service is unavailable.");
break;
}
}
try
{
client.endConnection();
}
catch (Exception ignored){}
}
@Override
public void onInstallReferrerServiceDisconnected()
{
// Do nothing, we need to fetch the information once and
// it is not really necessary to try to reconnect.
// If app is opened once more, the attempt will be made anyway.
}
});
}
catch (Exception e)
{
if (Fabric.isInitialized())
Crashlytics.logException(new IllegalStateException("Exception while fetching UTM information.", e));
}
}
else
Log.i(TAG, "UTM is already recorded, skipping connection initialization. Value: " +
utmData);
}
方法很简单,但数据似乎有误。那么,执行起来似乎有些不正确吗?如果不是,为什么从 Google Ads 收到的数据有误?任何帮助表示赞赏,非常感谢。
编辑:经过一些测试,这是我发现的:
作品:
一个 API 19 真实设备(GM Discovery II Mini)和安装了 Play 商店的 API 25-29 模拟器。编辑:UTM 也可以通过 API 23 和 24 Genymotion Emulators 获取,其中安装了 Play Store。
不起作用:
安装了最新的 Google Play 服务和 Play 商店的 API 24 Android Studio 模拟器(设备也登录到我的帐户),真实设备(通用移动 4G Dual,API 23)不能查询UTM信息。下面的代码落在InstallReferrerResponse.FEATURE_NOT_SUPPORTED 的情况下。所以我几乎可以肯定安装引用客户端在某些 API 级别上存在错误。
编辑:向 Google 提出问题:https://issuetracker.google.com/issues/149342702
【问题讨论】:
-
我可以问一下即时否决票的用途吗?
-
我们可以看到 processReferrer() 吗?另外,Google Ads 报告和 Firebase Analytics 之间的差异有多大?
-
@RishabhSagar 不幸的是,我不允许分享
processReferrer()方法,但错误基本上来自response.getInstallReferrer()。我确信这一点,因为使用广播接收器的旧系统,它可以完美地工作。 -
我添加了一个答案。这可能不是您想要的确切答案。 stackoverflow.com/a/60188740/3948854
-
到目前为止有什么解决方案吗? Android 应用的 Google Ads 广告系列跟踪似乎与官方推荐的 utm_source/utm_medium 不同。
标签: android firebase ads utm-tracking