我在Android应用中使用Google Analytics。但我在分析帐户中看不到任何数据。
请建议我如何使用它。
我使用以下方法来调用/共享分析。
AppAnalytics.shareAnalytics("Error","ButtonClick","Error occured on Bt1 click.");
AppAnalytics.java :
public class AppAnalytics extends Application {
private Context context;
public AppAnalytics(Context context) {
super();
this.context = context;
}
synchronized Tracker getTracker() {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
analytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
Tracker t = analytics.newTracker(R.string.analytics_id);
t.enableAdvertisingIdCollection(true);
return t;
}
public void shareAnalytics(String category, String action, String label) {
try {
Tracker t = getTracker();
t.send(new HitBuilders.EventBuilder().setCategory(category)
.setAction(action).setLabel(label).build());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}