Android Google Analytics

來源:互聯網
上載者:User

標籤:code   blog   build   debug   開始   level   rate   最新   計數   

項目中integrate了GA,碰到過一些問題:

1.Too many hits sent too quickly, rate limiting invoked

這個問題是發送hit(event/screen)太頻繁,超出了Google的限制。解決辦法是設定session timeout到一個合適的值,並且分段統一發送hit。

 

2.Google Play Services版本相容問題

由於裝置中Google Play Services版本太老,為了相容只得使用一個很老版本的Google Play Services。

compile ‘com.google.android.gms:play-services-base:6.5.87‘

這個版本中內建GA包,但包裡不含AnalyticsReceiver和AnalyticsService。

 

3.網路斷開後統計資料丟失

曾經出現過斷網一段時間然後網路恢複之後資料丟失。不但斷網期間的資料沒有,而且網路恢複後的資料不再繼續發送。

我更改了GoogleAnalytics Tracker的一些參數,但我還沒開始測試具體是哪項設定起了作用,這一點有待之後補充。

注意以下是Kotlin代碼

        analytics.setLocalDispatchPeriod(resources.getInteger(R.integer.ga_dispatchPeriod))        if (BuildConfig.DEBUG) {            analytics.logger.logLevel = com.google.android.gms.analytics.Logger.LogLevel.VERBOSE//            analytics.setDryRun(true)        }        tracker = analytics.newTracker(applicationContext.resources.getString(R.string.ga_trackingId))        tracker.setSessionTimeout(60)        tracker.enableExceptionReporting(true)        tracker.enableAdvertisingIdCollection(true)        tracker.enableAutoActivityTracking(true)

應該是localDispatchPeriod起的作用,但是要測試後才知道。

當然這個問題可能是由於GoogleAnalytics的版本問題。需要更新Google Play Services。可能如果使用最新的版本這個問題不會出現,這個我也還沒測試。

 

Android Google Analytics

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.