如何从 Google 分析转向 Firebase 分析?

背景资料

最近几个月,谷歌发布了一个新的分析替代品,名为“ Firebase Analytics ”。

问题是

由于应用程序已经有了谷歌分析,我发现一些障碍,我不知道如何最好地处理。

那些问题

  1. 以前,“ newTracker”函数需要一个属性 ID。现在我没有看到它。这是否意味着它不需要一个属性 ID?

  2. 在此之前,也可以使用“ ableAdvertisingIdCollection”来收集广告信息。我在新的 API 里找不到。是自动收集的吗?

  3. “ setDryRun”可以禁止向服务器发送数据,现在我看不到它了。这是否意味着应用程序的调试版本会自动采用这种方式?所有函数都写入日志吗?

  4. 以前,我可以追踪一个“屏幕”:

    public void setScreenName(String name) {
    mGoogleAnalyticsTracker.setScreenName(name);
    mGoogleAnalyticsTracker.send(new HitBuilders.ScreenViewBuilder().build());
    }
    

    现在我没有看到它,但是正如我所读到的,我认为它是自动的,所以它无论如何都会发送活动生命周期的数据。是真的吗?

  5. 也许最重要的是: 以前我可以使用分类、动作、标签和值来跟踪:

    public void trackEvent(final String category, final String action, final String label, final long value) {
    mGoogleAnalyticsTracker.send(new HitBuilders.EventBuilder()
    .setCategory(category).setAction(action)
    .setLabel(label).setValue(value).build());
    }
    

    现在我看到了一种完全不同的跟踪事件(“自定义事件”)的方法,使用 包裹。例如:

    Bundle bundle = new Bundle();
    bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id);
    bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
    bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
    mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
    

    它是怎么工作的?它是如何显示在 < strong > Firebase Analytics 网站 ?我想我可以让 logEvent 的第一个参数表现得像 Google-Analytics 的分类参数一样,但是我可以/应该为其余的参数做些什么呢?根据文件,这应该没问题:

    public void trackEvent(final String category, final String action, final String label, final long value) {
    Bundle bundle = new Bundle();
    bundle.putString("action", action);
    bundle.putString("label", label);
    bundle.putLong("value", value);
    mFirebaseAnalytics.logEvent(category, bundle);
    }
    
  6. Which events are actually automatically being tracked (I ask this because some are said that I shouldn't use, here) ? Do they include purchases? app-invites? ads? Where do I see them in the console website ?

  7. About logs, it says that the new SDK does it by :

    You can enable verbose logging with a series of adb commands:

    adb shell setprop log.tag.FA VERBOSE adb shell setprop log.tag.FA-SVC VERBOSE adb logcat -v time -s FA FA-SVC

    What do those commands do? How can I disable it? I've noticed it even gets shown in release version of the app...

  8. Is the new SDK supposed to replace Google-Analytics? Is it suggested to fully move to it? Will Google-Analytics have any updates?

27076 次浏览

Lots of questions bundled together so I'll try to briefly answer most of them:

  1. Google Analytics reports on tracker-ids, Firebase Analytics reports on applications. There is only one id in the application defined in your google-services.json. The ID is translated to a string resource by google services plugin under "google_app_id" name. All events from the app are reported to this single id.
  2. Firebase Analytics reports AdId automatically. You don't need to enable it.
  3. There is no dryRun feature. You can either use separate google-services.json during development, filter out development version using the app version or add user-property to mark the app instances used for development.
  4. You can report screens with

    Bundle params = new Bundle();
    params.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "screen");
    params.putString(FirebaseAnalytics.Param.ITEM_NAME, "screen name");
    firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, params);
    
  5. You can log custom event with the same params

    Bundle params = new Bundle();
    params.putString("category", category);
    params.putString("action", action);
    params.putString("label", label);
    params.putLong("value", value);
    firebaseAnalytics.logEvent("xyz_event", params);
    

    The "ga_" prefix is reserved and your analytics will fail if you use it. Instead, use "xyz_" where xyz is your company's initials, for example.

    Do not use the category as event name unless you have very few categories you want to track. Firebase Analytics supports up to 500 event names. Logging more than that will cause some of your data to be ignored.

  6. There is a list of reserved event names in the beginning of the FirebaseAnalytics.Event class. It roughly represents the automatic events reported.

  7. Firebase Analytics has debug logging disabled by default. It only logs errors and warnings. If you don't enable debug logging and your app is correctly configured there are only 2 lines that are being logged when the app starts with instructions on how to enable debug logging. There is nothing to disable in production and there is no equivalent to setLogLevel(ERROR) from Google Analytics. WARN is the default logging level. You can only enable logging on individual device by running the adb command on the device). That helps you avoid shipping app in production with debug logging enabled.

  8. Google Analytics SDK for Android and iOS is not deprecated and will be supported and updated for foreseeable future. You don't need to move away from it if you already invested using it in your app and it is meeting your needs.

Google Analytics is a freemium web analytics service offered by Google that tracks and reports website traffic.1 Google launched the service in November 2005 after acquiring Urchin. Firebase is a cloud services provider and backend as a service company based in San Francisco, California. The company makes a number of products for software developers building mobile or web applications.

How to move from google analytics to firebase analytics?

Google Analytics (GA) and Firebase Analytics (FA), despite their common name, are widely different in many aspects. While GA is a general-purpose (and more web oriented) analytics tool, Firebase was built keeping mobile in mind: therefore, the feature set is different between the two, with some things that were added in FA and things that are missing from GA.

More specifically, these are some noteworthy points when considering Firebase Analytics:

  • Real-time view is missing
  • Events are available after a 4-6 hours period
  • Behavior Flow (from GA) is missing
  • The Audiences feature a big advantage of FA and, coupled with Notifications, allows you to engage with a specific group of users
  • When using Firebase Crash Reporting, an audience with users who experienced a crash is automatically created
  • Funnel analysis makes much more sense than in GA, since FA is based on events and not on screen views
  • Free and unlimited, except for the number of types of events (limited to 500); no limits on the volume of events per each type
  • Some events are logged automatically (i.e., sessions based on Activity lifecycle)
  • Relatively low methods footprint, compared to GA's methods count
  • Dead-easy to setup, there is no singleton to initialize, just include the Gradle dependency and start logging events
  • All-in-one console, if you plan on using other Firebase services

As to if one should consider switching from one to the other, or if to keep both in parallel, the answer is: it depends.

  • If you were using GA extensively before, chances are that you would be missing some of its feature when switching completely to FA.
  • However, if this is a fresh start for your project, FA is much more prone to a cross-platform mobile-oriented environment, so you may very well consider it as your own analytics tool.

On a side note, keep in mind that Firebase has just launched and Google has plans on adding more features in the coming weeks (e.g., real-time dashboard).

For tutorial you can find here https://firebase.google.com/docs/analytics/android/start/