3

这里的最底层。有一个 URL 生成器,我可以在 google play 上生成指向我的应用程序的链接,并带有引用者。我怎样才能从谷歌分析中额外的活动来源?我一直在谷歌上搜索,但仍然找不到答案。我发现有人说我应该创建一个扩展 BroadcastReceiver 的类,但我也在这里找到了。这样做,我将无法获得 GA 工作。GA非常强大,我想用它。我现在需要的是从 GA 中提取引荐来源/广告系列来源的参数。我还发现在 EasyTracker.getTracker() 下有几个 getter,例如 getAppId()、getAppInstallerId() 和 getTrackingId(),但没有一个记录在案。我怎么知道哪个 ID getter 属于哪个?谢谢您的帮助!

4

1 回答 1

5

Although referrer/campaign tutorial document is in GA(google analytics) document,You can get Referrer information and use it in your app without implementing GA, see: 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>

Just change the 3rd line to your custom BroadCastReceiver example:

<!-- 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>

Your custom BroadCastReceiver maybe:

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);
  }
}
于 2015-02-02T15:57:16.473 回答