Android-跟踪应用程序首次在设备上启动的时间

Android-跟踪应用程序首次在设备上启动的时间,android,google-analytics,Android,Google Analytics,当应用程序首次在设备上启动时,我需要跟踪以下代码:, 然而,它与我从谷歌分析中获得的新用户类别的数据不匹配。有人能在代码中看到任何不可靠的东西吗?例如,今天我看到这段代码中有3个安装,但我有5个新用户只能从GooglePlay下载这个应用 String INSTALL_SOURCE = "Google Play"; TelephonyManager tm; tm = (TelephonyManager) getBaseContext().getSystemServ

当应用程序首次在设备上启动时,我需要跟踪以下代码:, 然而,它与我从谷歌分析中获得的新用户类别的数据不匹配。有人能在代码中看到任何不可靠的东西吗?例如,今天我看到这段代码中有3个安装,但我有5个新用户只能从GooglePlay下载这个应用

String INSTALL_SOURCE = "Google Play";
        TelephonyManager tm;
        tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
        String INSTALL_COUNTRY = tm.getSimCountryIso();
        prefs = getSharedPreferences("user_stats", MODE_PRIVATE);
        boolean firstTime = prefs.getBoolean("isFirstTime", true);
        if (firstTime) {
            rentracker.trackEvent("Install Source", INSTALL_SOURCE, INSTALL_COUNTRY, 1);
            Editor editor = prefs.edit();
            editor.putBoolean("isFirstTime", false);
            editor.commit();
        }
        Log.d(TAG, "Is this the first time?: " + firstTime);
        String android_id = Secure.getString(this.getContentResolver(),
                Secure.ANDROID_ID);
        rentracker.trackEvent("App Startup - " + INSTALL_SOURCE, INSTALL_COUNTRY, "ID: " + android_id,1);
有人能在代码中看到任何不可靠的东西吗

  • 正如一位评论者所建议的,仅仅因为这个代码存在并不意味着它实际上已经运行了,因为用户可能还没有启动您的活动。如果你认为这段代码会在没有用户参与的情况下自动运行,那么在Android 3.1及更高版本上可能就不是这样了

  • 据推测,
    rentracker
    应该通过互联网进行通信,但不是每个人都可以连续访问互联网。因此,可能是您的代码已经运行,但后端尚未发现,因为用户当时不在线

  • 您假设Play Store开发者控制台能够准确、及时地报告下载情况。Play Store Developer Console并不是人类历史上最可靠的软件,因此您的比较数据完全可能存在缺陷


  • 这可能不是问题,但有一个词是关于Secure.ANDROID_ID的唯一性!也许有些用户从Google Play安装了这个应用程序,但从来没有启动它让你的代码运行?你的第三点可能是我对这个问题的最好答案。我一直认为他们的数据是准确的。