简体   繁体   English

尝试将日志发送到Google Analytics(分析)仪表板时,是否应创建EasyTracker多重实例时间实例

[英]Should we create instance of EasyTracker multime times when trying to send logs to Google Analytics dashboard

I am using Google Analytics in android project. 我在android项目中使用Google Analytics。 For this wherever I'm sending analytics I'm creating object of EasyTracker class. 为此,无论我在哪里发送分析,都在创建EasyTracker类的对象。

Suppose user is on First Activity then I'm creating the object of EasyTracker in onCreate so when user navigate to second activity then again I'm creating object of EasyTracker in onCreate of second activity. 假设用户在“第一个活动”上,那么我将在onCreate创建EasyTracker的对象,因此当用户导航到第二个活动,然后再次在第二个活动的onCreate中创建EasyTracker对象。

Should we create object of EasyTracker once only and use it same in entire application or this does not matter. 我们应该只创建一次EasyTracker对象,然后在整个应用程序中使用它,还是没关系。 I guess that by creating two object of EasyTracker Google Analytics is assuming that there are two real time users but exact is only one. 我猜想,通过创建EasyTracker两个对象,Google Analytics(分析)假设有两个实时用户,但实际用户只有一个。

EasyTracker easyTracker = EasyTracker.getInstance(ActivityMain.this);

Thanks in advance. 提前致谢。

Look at sample: 看示例:

  @Override
  public void onStart() {
    super.onStart();
    ... // The rest of your onStart() code.
    EasyTracker.getInstance(this).activityStart(this);  // Add this method.
  }

  @Override
  public void onStop() {
    super.onStop();
    ... // The rest of your onStop() code.
    EasyTracker.getInstance(this).activityStop(this);  // Add this method.
  }

https://developers.google.com/analytics/devguides/collection/android/v3/ https://developers.google.com/analytics/devguides/collection/android/v3/

It seems that EasyTracker is singletone and you should call getInstance every time. EasyTracker似乎是单调的,您应该每次都调用getInstance。

You should consider switching to a newer v4 version of the Google Analytics SDK for Android. 您应该考虑切换到适用于Android的v4较新版本。 v4 of the API support automatic activity reporting - Tracker.enableAutoActivityTracking . API的v4支持自动活动报告-Tracker.enableAutoActivityTracking Once you enable automatic tracking it does the screen reporting for you. 启用自动跟踪后,它将为您执行屏幕报告。 Easy tracker is v2/v3 of the API and doesn't support many new features added to Google Analytics like demographics reporting. Easy Tracker是API的v2 / v3版本,不支持添加到Google Analytics(分析)的许多新功能,例如受众特征报告。 Google only maintains the latest version of the SDK so v2/v3 might not work that well on newer versions of Android. Google仅维护最新版本的SDK,因此v2 / v3在较新的Android版本上可能无法正常运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM