为什么我看不到我从移动谷歌分析中发送的事件?

时间:2012-11-22 13:59:39

标签: android google-analytics

我正在使用此代码(这是示例中的标准代码):

protected void onCreate(Bundle savedInstanceState){     super.onCreate(savedInstanceState);

tracker = GoogleAnalyticsTracker.getInstance();

// Start the tracker in manual dispatch mode...
tracker.startNewSession("UA-36435865-1", 10, this);
tracker.setDebug(true);

// ...alternatively, the tracker can be started with a dispatch interval (in seconds).
//tracker.startNewSession("UA-YOUR-ACCOUNT-HERE", 20, this);

setContentView(R.layout.main);
Button createEventButton = (Button)findViewById(R.id.NewEventButton);
createEventButton.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
    tracker.trackEvent(
        "Clicks",  // Category
        "Button",  // Action
        "clicked", // Label
        77);       // Value
  }
});

Button createPageButton = (Button)findViewById(R.id.NewPageButton);
createPageButton.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
    // Add a Custom Variable to this pageview, with name of "Medium" and value "MobileApp"
    tracker.setCustomVar(1, "Medium", "Mobile App");
    // Track a page view. This is probably the best way to track which parts of your application
    // are being used.
    // E.g.
    // tracker.trackPageView("/help"); to track someone looking at the help screen.
    // tracker.trackPageView("/level2"); to track someone reaching level 2 in a game.
    // tracker.trackPageView("/uploadScreen"); to track someone using an upload screen.
    tracker.trackPageView("/testApplicationHomeScreen");
  }
});

Button quitButton = (Button)findViewById(R.id.QuitButton);
quitButton.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
    finish();
  }
});

Button dispatchButton = (Button)findViewById(R.id.DispatchButton);
dispatchButton.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {
    // Manually start a dispatch, not needed if the tracker was started with a dispatch
    // interval.
    tracker.dispatch();
  }
});

}

protected void onDestroy(){     super.onDestroy();     //在不再需要时停止跟踪器。     tracker.stopSession();   }

当看到logcat时,我发现它传输正常。

您认为这是什么问题?

1 个答案:

答案 0 :(得分:1)

3天后我找到了解决方案。

当我使用谷歌的标准SDK示例时,使用谷歌分析lib ver 1(libGoogleAnalytics.jar),但是当从谷歌分析网站引用时,他们说我们应该使用协议的第2版(libGoogleAnalyticsV2.jar) )。所以我想sdk中的例子还没有更新......

无论如何,这不是很好。