我的应用中有一个webview,并设置如下内容:
mWebView.loadUrl("http://.......");
我的Google Analytics跟踪器如下所示:
public synchronized Tracker getTracker(TrackerName trackerId) {
if (!mTrackers.containsKey(trackerId)) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker t = (trackerId == TrackerName.APP_TRACKER) ? analytics
.newTracker(R.xml.app_tracker)
: (trackerId == TrackerName.GLOBAL_TRACKER) ? analytics
.newTracker(PROPERTY_ID) : analytics
.newTracker(R.xml.ecommerce_tracker);
mTrackers.put(trackerId, t);
}
return mTrackers.get(trackerId);
}
我的问题是,如何使用此跟踪器跟踪我的网页浏览中加载的网址?
由于
答案 0 :(得分:0)
只需扩展onPageFinished方法
mWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// String url is what you are looking for
// Do the analytics stuff here
}
});