调试Android Analytics事件跟踪 - Google Analytics不会收集事件

时间:2016-03-14 14:56:54

标签: android google-analytics

我已成功将Google Analytics添加到Android应用中,并且正在提取会话数据。但是,我也尝试跟踪特定事件,但它似乎不会像其他会话数据一样发送到Google Analytics。我已经按照当前Google Analytics文档中建议的代码进行操作,但仍然没有运气,所以我在这里粘贴,希望对于经验丰富的人来说这是显而易见的。非常感谢任何指导。

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_data_import);
    user = getIntent().getStringExtra("user");
    statusUpdateArea = (EditText)findViewById(R.id.dataStatusUpdateField);
    progressBar = (ProgressBar)findViewById(R.id.progressBar);
    progressBar.setVisibility(View.INVISIBLE);
    welcomeMessage = (TextView)findViewById(R.id.WelcomeMessageTextView);
    welcomeMessage.append(user);
    // getting tracker & setting User ID field
    AnalyticsApplication application = (AnalyticsApplication) getApplication();
    mTracker = application.getDefaultTracker();
    mTracker.set("&uid", user);
    // build and send event
    mTracker.send(new HitBuilders.EventBuilder()
            .setCategory("User ID")
            .setAction("Data login")
            .setLabel(user)
            .build());
    ...

2 个答案:

答案 0 :(得分:0)

也许你需要使用

var someData = $('#someForm').serialize(); // form with data
var btnAjaxSubmit = $('.btnAjaxSubmit'); // button (type: button) to submit data

$('.btnAjaxSubmit').click(function() {
  var request = $.ajax({
    url: "https://somesite.com/data.asp",
    method: "POST",
    data: someData
  });

  // getting response 
  request.done(function(status) {
    console.log(status['response']);

    // response ok
    if (status['response'] === "ok") {
      alert('status is "updated"')
        // session timeout
    } else if (status['response'] === "timeout") {
      alert('log in again.');
      // all other cases
    } else {
      alert('this is the other case');
    }
  });

  // no response at all
  request.fail(function(status) {
    alert('request failed!');
  });
});

mTracker = application.getTracker();

答案 1 :(得分:0)

在调用build之前,似乎你正在调用send。 创建一个包含所有事件信息的跟踪器,然后调用构建和完成调用发送功能。

曾参与过webtrends分析产品,因此我对分析了解了一两件事