【问题标题】:Android: Receiving wrong UTM from Google AdsAndroid:从 Google Ads 接收错误的 UTM
【发布时间】: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


【解决方案1】:

由于我不知道您是如何处理响应的,所以我可以向您展示我们在实施中的处理方式。

ReferrerDetails response = referrerClient.getInstallReferrer();
if (response == null) {
    break;
}

String[] installReferrer = response.getInstallReferrer().split("&");

if (installReferrer.length >= 1) {
    utmSource = installReferrer[0].split("=")[1];
} 
if (installReferrer.length >= 2) {
    utmMedium = installReferrer[1].split("=")[1];
}

将此 sn-p 与您的进行比较,并检查是否有任何不同。

【讨论】:

  • 不幸的是,response.getInstallReferrer() 方法在这种情况下返回了错误的值。这就是为什么使用此方法解析的字符串实际上也是错误的。所以,恐怕这不是解决方案。
  • 嘿@FurkanYurdakul,我认为您在 Google Ads 中使用的跟踪网址格式可能存在问题。您是否尝试过使用此工具构建跟踪 URL developers.google.com/analytics/devguides/collection/android/v4/… 。此外,将此工具生成的 URL 与当前 URL 进行比较。
  • 嗯。如果是这种情况,我猜 Google Ads 本身会生成错误的值吗?因为在手动创建和重定向时,UTM 被正确获取。你以前遇到过类似的事情吗?
  • 我们从未尝试过衡量 Google Ads 安装量,但我们确实实施了一个推荐系统,该系统需要创建一个推荐链接(我在上面的评论中提到了类似的东西)。这样,我们就能够跟踪用户安装应用程序的实际来源。如果我没记错的话,我记得我们可以在 Google Ads Dashboard 中创建广告时提供跟踪 URL。你可以试试看。
猜你喜欢
  • 2019-03-08
  • 1970-01-01
  • 2023-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-08
  • 1970-01-01
相关资源
最近更新 更多