我已将分析v2升级到v3,但现在我无法跟踪信息,如果我转到谷歌分析页面,所有统计信息都是空的。我正在做非常简单的跟踪:
AnalyticsManager:
private static final String APP_LIFECYCLE_CATEGORY = "Application - Android";
private static final String APP_OPEN = "Android - App Open";
private static final String APP_CLOSE = "Android - App Closed";
public static void setup(Context context) {
gaInstance = GoogleAnalytics.getInstance(context);
gaTracker = gaInstance.getTracker(C.isAnalyticsInQA() ? C.ANALYTICS_TEST_KEY : C.ANALYTICS_RELEASE_KEY);
gaInstance.setDefaultTracker(gaTracker);
gaInstance.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
}
public static void tearDown() {
gaInstance.closeTracker(gaTracker.getName());
}
public static void trackAppCloseEvent() {
gaTracker.send(MapBuilder
.createEvent(APP_LIFECYCLE_CATEGORY, APP_CLOSE, "", 0L)
.set(Fields.SESSION_CONTROL, "start")
.build());
}
public static void trackAppOpenEvent() {
gaTracker.send(MapBuilder
.createEvent(APP_LIFECYCLE_CATEGORY, APP_OPEN, "", 0L)
.set(Fields.SESSION_CONTROL, "close")
.build());
}
应用
@Override
public void onCreate() {
super.onCreate()
...
AnalyticsManager.setup(this);
AnalyticsManager.trackAppOpenEvent();
}
@Override
public void onTerminate() {
AnalyticsManager.trackAppCloseEvent();
AnalyticsManager.tearDown();
...
super.onTerminate();
}
有同样问题的人吗? 顺便说一句,如果我没有指定查询参数“?hl =”,那么所有谷歌分析开发指南都会给我HTTP 500。这应该发生吗?我以前从未指定过......
https://developers.google.com/analytics/devguides/collection/android/v3/migration?hl=en
答案 0 :(得分:2)
我不知道v4已经在@Pooja提到了。迁移到v4,它完美运行。