我在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扩展 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)。
正确的行为应该是empty event,pageView,emptyEvent,pageView(来自
onStop
,onStart
,onStop
和onStart
)。在一次调度中跟踪多个事件(使用
EasyTracker.getTracker().trackEvent
)时,这也是错误的。有人有类似的问题吗?
最佳答案
原来是libGoogleAnalytics.jar 1.4.2中的错误
在AsyncDispatchTask.dispatchSomePendingHits
中的NetworkDispatcher.DispatcherThread
函数中
在for循环中,调用requesterCallBacks.requestSent()
,这会从匹配列表中删除元素。
大多数情况下,这是干燥模式,但有时可能会在正常模式下发生(当命中的字符串长度大于8k时),但是如果发生以下情况,您将得到警告:
Log.w("GoogleAnalyticsTracker", "Hit too long (> 8192 bytes)--not sent");
因此,只需确保您的事件和pageViews不太长即可。
关于Android EasyTracker无法正常工作?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9241311/