我已经为谷歌分析 api v4 设置了所有东西,因为它在这里提到:
https ://developers.google.com/analytics/devguides/collection/android/v4/
和这里:
http ://www.javacodegeeks.com/2014 /04/working-with-google-analytics-api-v4-for-android.html
我可以看到实时数据,但在“所有时间”等特定时间段内看不到屏幕、活跃用户、新用户和顶级设备型号。
Analytic 不发送屏幕视图。
这是我的global_tracker.xml
<string name="ga_trackingId">UA-XXXXXXXX-Y</string>
<integer name="ga_sessionTimeout">300</integer>
<bool name="ga_autoActivityTracking">true</bool>
<bool name="ga_reportUncaughtExceptions">true</bool>
<screenName name="com.org.ScreenActivity1">Screen 1</screenName>
<screenName name="com.org.ScreenActivity2">Screen 2</screenName>
这是我的AndroidManifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/global_tracker"/>
这是我的Analytics.java
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>();
public Analytics() {
super();
}
public synchronized Tracker getTracker(TrackerName trackerId) {
if (!mTrackers.containsKey(trackerId)) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
if (trackerId == TrackerName.GLOBAL_TRACKER) {
mTrackers.put(trackerId, analytics.newTracker(R.xml.global_tracker));
}
}
return mTrackers.get(trackerId);
}
这是我的活动课:
protected void onCreate(Bundle bundle){
//......................
Tracker tracker = ((Analytics) getApplication()).getTracker(Analytics.TrackerName.GLOBAL_TRACKER);
tracker.setScreenName("Main Activity");
tracker.send(new HitBuilders.AppViewBuilder().build());
//......................
}
@Override
protected void onStart() {
super.onStart();
GoogleAnalytics.getInstance(this).reportActivityStart(this);
}
@Override
protected void onStop() {
super.onStop();
GoogleAnalytics.getInstance(this).reportActivityStop(this);
}