I set up a helper class which reports events and screens to Google Analytics
, via the EasyTracker
, for an unknown reason each time I relaunch the app, it reports all the screen and the events as a new user.I checked the gaClientId
file, which store a unique ID.but each time I relaunch the app, the ID stored in this file changes, compared to other apps where is stays the same.
here is the code I use in my helper class, note that I've tried using ApplicationContext context as well.I tried disabling the instant dispatch (and yes I know its not good practice reporting it immediately)
private static String mLastView = "";
public static void sendView(String view,Context ctx) {
// Don't report screen twice in a row
if(view.equals(mLastView)) return;
mLastView = view;
EasyTracker.getInstance().setContext(ctx);
EasyTracker.getTracker().sendView(view);
EasyTracker.getInstance().dispatch();
}
public static void sendEvent(Context ctx,String category,String action,String label,long value){
EasyTracker.getInstance().setContext(ctx);
EasyTracker.getTracker().sendEvent(category, action, label, value);
EasyTracker.getInstance().dispatch();
}
Update:
I've tried using the GoogleAnalytics class without the easy tracker,but still doesn't work.I guess there some sort of read permission issue (but can write it?), the file located at data/data/com.my.app/files/gaClientId
Update:
I've tried anything, I can read the gaClientId
file manually, no problem whatsoever, tired reporting with and without helper class, still create a new ClientID each launch of the app.