我在Android上使用GoogleAnalytics EasyTracker时遇到问题
我为这个问题所做的设置很简单:
- 新的Android项目
- 添加GA和ET库
- 添加GoogleAnalytics.xml:
<resources>
<string name="ga_api_key">UA-2912-1</string>
<bool name="ga_debug">true</bool>
<bool name="ga_dryRun">true</bool>
<bool name="ga_auto_activity_tracking">true</bool>
<integer name="ga_dispatchPeriod">10</integer>
</resources>
使用TrackedActivity而不是Activity来扩展活动:
package test.testing.ez;
import android.os.Bundle;
import com.google.android.apps.analytics.easytracking.TrackedActivity;
public class TestEZActivity extends TrackedActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
最后,在模拟器或设备上运行我的简单应用程序后,在切换方向两次后,我的LogCat中会出现类似的内容。
02-11 14:39:27.245: I/GoogleAnalyticsTracker(219): Host: www.google-analytics.com
02-11 14:39:27.245: I/GoogleAnalyticsTracker(219): User-Agent: GoogleAnalytics/1.4.2 (Linux; U; Android 2.1-update1; en-us; sdk Build/ECLAIR)
02-11 14:39:27.245: I/GoogleAnalyticsTracker(219): GET /__utm.gif?utmwv=4.8.1ma&utmn=1604828210&utmt=event&utme=5(**)(0)&utmcs=UTF-8&utmsr=480x320&utmul=en-US&utmac=UA-2912-1&utmcc=__utma%3D1.659024508.1328970962.1328970962.1328971039.2%3B&utmht=1328971157185&utmqt=10064 HTTP/1.1
02-11 14:39:27.294: I/GoogleAnalyticsTracker(219): Host: www.google-analytics.com
02-11 14:39:27.294: I/GoogleAnalyticsTracker(219): User-Agent: GoogleAnalytics/1.4.2 (Linux; U; Android 2.1-update1; en-us; sdk Build/ECLAIR)
02-11 14:39:27.294: I/GoogleAnalyticsTracker(219): GET /__utm.gif?utmwv=4.8.1ma&utmn=1061578751&utmt=event&utme=5(**)(0)&utmcs=UTF-8&utmsr=480x320&utmul=en-US&utmac=UA-2912-1&utmcc=__utma%3D1.659024508.1328970962.1328970962.1328971039.2%3B&utmht=1328971161689&utmqt=5611 HTTP/1.1
02-11 14:39:27.314: I/GoogleAnalyticsTracker(219): Host: www.google-analytics.com
02-11 14:39:27.314: I/GoogleAnalyticsTracker(219): User-Agent: GoogleAnalytics/1.4.2 (Linux; U; Android 2.1-update1; en-us; sdk Build/ECLAIR)
02-11 14:39:27.314: I/GoogleAnalyticsTracker(219): GET /__utm.gif?utmwv=4.8.1ma&utmn=1061578751&utmt=event&utme=5(**)(0)&utmcs=UTF-8&utmsr=480x320&utmul=en-US&utmac=UA-2912-1&utmcc=__utma%3D1.659024508.1328970962.1328970962.1328971039.2%3B&utmht=1328971161689&utmqt=5623 HTTP/1.1
02-11 14:39:27.324: I/GoogleAnalyticsTracker(219): Host: www.google-analytics.com
02-11 14:39:27.324: I/GoogleAnalyticsTracker(219): User-Agent: GoogleAnalytics/1.4.2 (Linux; U; Android 2.1-update1; en-us; sdk Build/ECLAIR)
02-11 14:39:27.324: I/GoogleAnalyticsTracker(219): GET /__utm.gif?utmwv=4.8.1ma&utmn=1210083032&utmcs=UTF-8&utmsr=480x320&utmul=en-US&utmp=%2Ftest.testing.ez.TestEZActivity&utmac=UA-2912-1&utmcc=__utma%3D1.659024508.1328970962.1328970962.1328971039.2%3B&utmht=1328971161800&utmqt=5524 HTTP/1.1
前三个是空事件(utme = 5(**)(0)),最后一个是pageView(utmp =%2Ftest.testing.ez.TestEZActivity)。
正确的行为应该是空事件,pageView,emptyEvent,pageView(来自onStop
,onStart
,onStop
和onStart
)。
在一次调度期间跟踪多个事件(EasyTracker.getTracker().trackEvent
)时,这也是错误的
有人有类似的问题吗?
答案 0 :(得分:1)
原来这是libGoogleAnalytics.jar 1.4.2中的一个错误
AsyncDispatchTask.dispatchSomePendingHits
中的函数NetworkDispatcher.DispatcherThread
在for循环中requesterCallBacks.requestSent()
被调用,它从命中列表中删除元素
这种情况主要适用于干模式,但有时可能会在正常模式下发生(当命中字符串长度大于8k时),但如果发生这种情况,您将收到警告:
Log.w("GoogleAnalyticsTracker", "Hit too long (> 8192 bytes)--not sent");
所以请确保您的活动和网页浏览不会太长。