2

在 Android 上使用 Google Analytics SDK 处理广告系列测量(请参阅此处)时,获取推荐人的最佳方式是什么?

我可以成功地向我的应用程序广播意图,并且在我的日志中看到找到了该活动。我需要做的是获取该引荐来源信息并将其发送到我的服务器以进行日志记录等。当我手动广播时,我在哪里可以解析此引荐来源并使用它?当我的应用程序上线时,我的代码应该在哪里,以便在安装时将此引荐来源网址发送到我的服务器?

4

1 回答 1

4

您可以实现自己的接收器,referral从意图中获取额外的字符串INSTALL_REFERRER,执行一些工作,然后将意图传递给 Google Analytics 接收器。

这是一个例子:

package com.example.app;

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

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


public class NotePadReceiver extends BroadcastReceiver {

  // The name of the referrer string broadcast by Google Play Store.
  private static final String PLAY_STORE_REFERRER_KEY = "referrer";

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

    String referrer = intent.getStringExtra(PLAY_STORE_REFERRER_KEY);

    // Do something with the referrer.

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

  }
}
于 2013-10-23T21:34:39.477 回答