EasyTracker (GA) every application launch is reported as a new user

I installed a helper class that reports events and screens Google Analyticsthrough EasyTrackerfor an unknown reason every time I restart the application, it reports all the screen and events as a new user. checked the file gaClientIdin which the unique ID.but is stored, every time I restart the application, the identifier stored in this file changes compared to other applications where it remains the same.

here is the code that I use in my helper class, note that I also tried using the ApplicationContext context. I tried disabling instant sending (and yes, I know this is not a 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: GoogleAnalytics , . , - ( ?), , data/data/com.my.app/files/gaClientId

Update: -, gaClientId , , , - ClientID .

+5
2

, ? , ClientID, data/data/com.my.app/files/gaClientId, , .. , , content.thus, , gaClientId ,

files

+4

, . : onCreate() :

gaInstance = GoogleAnalytics.getInstance(this);
    tracker = gaInstance.getDefaultTracker()

gaInstance - .

onStart() :

tracker.sendView("/youractivity");

. :

            tracker.sendEvent("String",
                    "String",
                    "String",
                    "long");

, , analytics.xml. 30 , 30

<integer name="ga_sessionTimeout">1800</integer>
+1

All Articles