1
我正在嘗試使用Google Analytics工具來跟蹤我的應用使用情況。但是我的Google Analytics帳戶沒有顯示訪問者/訪問者。我多次使用過我的應用程序。我也設置了按鈕點擊事件。但它什麼也沒有顯示。我也有一個有效的鑰匙。谷歌分析工具
import com.google.android.apps.analytics.GoogleAnalyticsTracker;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class GoogleAnalysis extends Activity {
GoogleAnalyticsTracker tracker;
GoogleAnalyticsTracker mGATracker;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* try{ mGATracker = GoogleAnalyticsTracker.getInstance();
mGATracker.startNewSession(" UA-xxxxx-x", this);
mGATracker.trackPageView("/SettingsMangerActivity"); } catch(
Exception error) { Log.e("<YOUR_TAG>", "onCreate: " +
error.toString()); }
*/
tracker = GoogleAnalyticsTracker.getInstance();
tracker.startNewSession(" UA-30927539-1", this);
setContentView(R.layout.googleanlytics);
Button createEventButton = (Button) findViewById(R.id.NewEventButton);
createEventButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tracker.trackPageView("/SettingsMangerActivity");
tracker.trackEvent("Clicks", "Button", "Share Files", 0);
}
});
Button createPageButton = (Button) findViewById(R.id.NewPageButton);
createPageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tracker.setCustomVar(1, "Navigation Type", "Button click", 2);
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();
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
// Stop the tracker when it is no longer needed.
tracker.stopSession();
}
}
您是否檢查了您的權限以確保您的應用可以訪問互聯網? – shanabus 2012-04-18 20:35:01