我在我的应用程序中包含了谷歌分析。但是当我创建Tracker
跟踪器的对象时不起作用
我的一项活动中的代码
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
try{
tracker=((GoogleAnalyticsConfig)this.getApplication()).getTracker(GoogleAnalyticsConfig.TrackerName.APP_TRACKER);
tracker.setScreenName("HomeActivity");
tracker.send(new HitBuilders.AppViewBuilder().build());
}catch(Exception ex)
{
ex.printStackTrace();
}
}
现在有了这段代码,我在实时跟踪中看不到应用程序,但是如果我用这个更改上面的代码
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
try{
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
analytics.reportActivityStart(this);
}catch(Exception ex)
{
ex.printStackTrace();
}
}
我可以看到一位用户在实时中处于活动状态
代码GoogleAnalyticsConfig
public 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.
}
HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
// The following line should be changed to include the correct property id.
private static final String PROPERTY_ID ="UA-XXXXXXXX-1";
public synchronized Tracker getTracker(TrackerName trackerId) {
if (!mTrackers.containsKey(trackerId)) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker t = analytics.newTracker(PROPERTY_ID);
t.enableAutoActivityTracking(true);
mTrackers.put(trackerId, t);
}
return mTrackers.get(trackerId);
}
谁能告诉我为什么跟踪器不工作?不仅是实时的,而且在我包含跟踪器的所有屏幕中,即使在 48 小时后,它也没有显示在 Google Analytics 的应用程序概述部分中。