简体   繁体   English

在Android中的TabActivity中使用Google Analytics(分析)

[英]Using Google Analytics in a TabActivity in android

I have a TabActivity in android that adds 4 separate activities to a TabHost. 我在Android中有一个TabActivity,可将4个单独的活动添加到TabHost。

On the onCreate of the TabActivity I call: 在TabActivity的onCreate上,我称之为:

tracker = GoogleAnalyticsTracker.getInstance();
tracker.start("MY UNIQUE GA CODE HERE", 10, getApplication());

And on the TabActivity onDestroy() I have 在TabActivity onDestroy()上

tracker.stop();

On the onResume of each activity added to the TabHost I have: 在添加到TabHost的每个活动的onResume上,我具有:

tracker = GoogleAnalyticsTracker.getInstance();
tracker.trackPageView("/ActivityTitle");

Is this the best way to do this, I have seen different methods but none consistant, eg adding the start method to each activity - but wouldn't this inflate the unique views? 这是执行此操作的最佳方法吗?我见过不同的方法,但并不一致,例如,将start方法添加到每个活动中-但这是否会使唯一的视图膨胀呢?

Any help much appreciated Thanks in advance 任何帮助,不胜感激,谢谢

Update 更新资料

I have finally got some stats through and eveything seems to be working, I will reserve judgement on the time spent in app average but 'appears' to be correct. 我终于有了一些统计数据,并且一切似乎都可以正常进行,我将对应用平均花费的时间做出判断,但“看来”是正确的。 any input for best practice much appreciated. 非常感谢您提供最佳做法的任何意见。 PS I get a warning in eclipse that the .start() and .stop() methods are depreciated, Googles documentation has not been updated yet so cant see a better way to do this, if you know please add. PS我在日食中收到警告,.start()和.stop()方法已过时,Google的文档尚未更新,因此,如果您知道,请添加更好的方法。 Thanks. 谢谢。

Bit late, sorry for that. 有点晚了,对此表示抱歉。 You might use the EasyTracker for multiple activities: http://code.google.com/p/analytics-api-samples/downloads/list 您可以将EasyTracker用于多种活动: http : //code.google.com/p/analytics-api-samples/downloads/list

With this lib you can simply extend the TrackedActivity and don't have to worry about where to start/stop etc. 有了这个库,您可以简单地扩展TrackedActivity,而不必担心从哪里开始/停止等。

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

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