Google Analytics v4无法看到实时点击

时间:2014-10-17 10:46:48

标签: java android google-analytics

我刚开始使用GAV4。

我跟着并仔细阅读了getting started tutorial。 我已设置所需的所有权限,并将其getTracker代码放在一个驻留的类中 在Application类中,为我需要全局访问数据的所有应用程序片段提供服务。

以下是代码:

public static enum TrackerName {
    APP_TRACKER, // Tracker used only in this app.
    GLOBAL_TRACKER, // Tracker used by all the apps from a company. eg: roll-up tracking.
    ECOMMERCE_TRACKER, // Tracker used by all ecommerce transactions from a company.
  }

  private static HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();


 synchronized static public Tracker getTracker(Application thisApp) {
        if (!mTrackers.containsKey(TrackerName.APP_TRACKER)) {


          GoogleAnalytics analytics = GoogleAnalytics.getInstance(thisApp);
          GoogleAnalytics.getInstance(thisApp).getLogger().setLogLevel(LogLevel.VERBOSE);
          Tracker t =
                  analytics.newTracker(thisApp.getResources().getString(R.string.app_tracker_property_id));
          mTrackers.put(TrackerName.APP_TRACKER, t);

        }
        return mTrackers.get(TrackerName.APP_TRACKER);
      }

注意我只需要一个应用跟踪器,因此我删除了有关全球跟踪器和电子商务跟踪器的部分。此外,R.string.app_tracker_property_id是我正确的属性ID,格式为UA-XXXXXXXX-1。

这里是我放在片段onCreate中的代码来计算屏幕命中数:

    Tracker tracker = ((AppCore)getActivity().getApplication()).getTracker();
    tracker.setScreenName("settings");
    tracker.send(new HitBuilders.AppViewBuilder().build());

当我进入此屏幕时会发生什么,我发现没有找到广告系列数据&#34;打印到logcat(据我所知是可以的),以及来自记录器的详细消息,其中说明客户端ID是从磁盘加载的,成功连接到Analytics服务,之后是命中发送到服务器:

10-17 13:22:52.093: V/GAV4(23153): Thread[client_id_fetcher,5,main]: Loaded client id from disk.
10-17 13:22:57.098: V/GAV4(23153): Thread[GAThread,5,main]: connecting to Analytics service
10-17 13:22:57.138: V/GAV4(23153): Thread[GAThread,5,main]: connect: bindService returned true for Intent { act=com.google.android.gms.analytics.service.START cmp=com.google.android.gms/.analytics.service.AnalyticsService (has extras) }
10-17 13:22:57.143: I/GAV4(23153): Thread[GAThread,5,main]: No campaign data found.
10-17 13:22:57.143: V/GAV4(23153): Thread[GAThread,5,main]: Initialized GA Thread
10-17 13:22:57.173: V/GAV4(23153): Thread[main,5,main]: service connected, binder: android.os.BinderProxy@414e2760
10-17 13:22:57.173: V/GAV4(23153): Thread[main,5,main]: bound to service
10-17 13:22:57.178: V/GAV4(23153): Thread[main,5,main]: Connected to service
10-17 13:22:57.208: V/GAV4(23153): Thread[GAThread,5,main]: Loaded clientId
10-17 13:22:57.213: V/GAV4(23153): Thread[GAThread,5,main]: Loaded clientId
10-17 13:22:57.213: V/GAV4(23153): Thread[GAThread,5,main]: putHit called
10-17 13:22:57.213: V/GAV4(23153): Thread[GAThread,5,main]: Sending hit to service   (ommited details)

但由于某些原因,我无法获得GA网站中RealTime视图的任何详细信息。选中的整个选项卡和所有图表都是空的。是因为我的帐户是新创建的(在SO中读取我需要等待至少1天,但它已经过去了),或者我做错了什么?

1 个答案:

答案 0 :(得分:3)

问题已解决......只需等待一两天......

是的,这可能令人沮丧,但我只能在2-3天后才能看到结果,所以请确保你做得对(它非常简单)并保持耐心。