Google analytics with fragment
android, android-fragments, google-analytics
Solution
In your Fragment:
@Override
public void onStart() {
super.onStart();
EasyTracker tracker = EasyTracker.getInstance(getActivity());
tracker.set(Fields.SCREEN_NAME, "Screen Name");
tracker.send(MapBuilder.createAppView().build());
}
Reference:
https://developers.google.com/analytics/devguides/collection/android/v2/screens#manual https://developers.google.com/analytics/devguides/collection/android/v3/migration#v2
Problem
I am using fragments in my app. Every fragment takes the whole screen. Is there any way to do `EasyTracker.getInstance().activityStart(activity);` to a fragment? I need to do that so I can see the "Avg. Time on Screen" of each of the fragments. Thanks!