android - Android 的 Google Analytics 调度周期

标签 android google-analytics

我正在使用最新版本的 Google Play 服务,以便将 Google Analytics(分析)与我的 Android 应用结合使用。我尝试将调度间隔设置为仅 1 秒,以便我可以在实时分析仪表板中看到它。但是,至少需要 3 分钟才能实时显示。我怎样才能让它立即或一分钟内显示?

这是我的代码:

GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
final Tracker t = analytics.newTracker("UA-XXXXX-X");
analytics.setLocalDispatchPeriod(1);

我需要以编程方式完成此操作,而不是在 XML 文件中。 我还应该提到我正在跟踪一个事件。 3 分钟后,它似乎始终出现在实时分析中。

感谢您的帮助。

最佳答案

setLocalDispatchPeriod() 现已弃用一段时间了。

The reason for the deprecation is outlined in the ServiceManager JavaDoc:

This only works if local dispatching is in use. Local dispatching is only used in the absence of Google Play Services on the device or if manually forced (see setForceLocalDispatch()). In general, applications can not rely on the ability to set the dispatch period. This method should therefore be used with some discretion.

If you are using EasyTracker, you can also specify ga_dispatchPeriod in your analytics.xml file, which should not throw a lint warning about deprecation.

<resources>
  <string name="ga_trackingId">UA-XXXXXXXX-X</string>

  <integer name="ga_dispatchPeriod">1</integer>

  <!-- [...] -->
</resources>

来源:https://stackoverflow.com/a/20618219/3848666通过 Tanis.7x

关于android - Android 的 Google Analytics 调度周期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24539116/

相关文章:

sql - _TABLE_SUFFIX 丢失?

android - 将菜单项设置为从代码中检查

android - 如何在另一个recyclerview适配器下使用recyclerview适配器?

java - actionbarpull 的 gradle 文件有问题

google-analytics - 什么是属性点击量?

google-analytics - 设置后更新每 session 自定义维度的值?

android - 为什么我的第一个选项卡不显示?

java - 如何从 fragment 中调用类

google-analytics - 如何跟踪 next.js 项目中的初始页面浏览量?

google-analytics - 实现没有 "thank you page"的目标