我们如何使用谷歌分析 v4 跟踪片段?
这是我的应用程序类:
public class MyApplication extends Application {
private static final String PROPERTY_ID = "UA-XXXXXXX-1";
public static int GENERAL_TRACKER = 0;
public enum TrackerName {
APP_TRACKER
}
HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
public MyApplication() {
super();
}
synchronized Tracker getTracker(TrackerName trackerId) {
if (!mTrackers.containsKey(trackerId)) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker t = analytics.newTracker(R.xml.app_tracker);
mTrackers.put(trackerId, t);
}
return mTrackers.get(trackerId);
}
}