Android webview 应用程序和 Google Analytics [英] Android webview app and Google Analytics
问题描述
我有一个简单的原生 Android 应用程序,它是一个网站的网络视图,如果您愿意,可以有效地使移动就绪的网站类似于原生网站.该网站已经安装了 Google Analytics.
I have a simple native Android app that is a webview of a website, effectively to make the mobile-ready site native-like if you will. The website already has Google Analytics installed.
跟踪哪些访问者正在使用应用程序的好方法是什么?
What might be a good way to track which visitors are using the app?
- 我可以添加 Android Native App Tracking,但我认为这会双重跟踪用户.除非它足够聪明来连接访问?
- 我可以将自定义 get 变量传递给可能添加 自定义归因于 对本机应用程序用户的跟踪.但这并没有听起来很干净.
- I could adding Android Native App Tracking, but I presume that would double track the users. Unless it's smart enough to connect the visits?
- I could pass custom get variable to the site that maybe adds a custom attribute to the tracking for native app users. But that doesn't sound very clean.
什么最适合跟踪?我觉得我错过了一个明显的答案.
What might be best for tracking? I feel there's got to be an obvious answer I'm missing.
推荐答案
应该对您有所帮助:
现在回到这个网络应用程序的分析跟踪,我在这里使用了谷歌提供的代码.于是代码就变成了这个样子.
Now getting back to the Analytics tracking of this web app, I used the code provided by Google here. So the code becomes somewhat like this.
public class myWebApp extends Activity{
Webview mWebview;
GoogleAnalyticsTracker tracker;
protected void onCreate(Bundle savedInstanceState) {
tracker = GoogleAnalyticsTracker.getInstance();
// Start the tracker in manual dispatch mode. The following UA-xxxxxxx-x code must be replaced by //your web property ID.
tracker.startNewSession("UA-xxxxxxx-x", this);
mWebview = new WebView(this);
mWebview .setWebViewClient(new myWebViewClient());
mWebview .loadUrl("file:///android_asset/www/index.html");
private class myWebViewClient extends WebViewClient
{
//After the user visits a particular page, send the tracking notification to GoogleAnalytics.
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
tracker.trackPageView( mWebview.getUrl());
tracker.dispatch();
}
}
}
http://www.the4thdimension.net/2011/11/using-google-analytics-with-html5-or.html
在谷歌分析的统计数据中,你至少应该得到一些关于 android 操作系统的信息.
And in stats of google analytics you should get some info at least about operating system android.
这篇关于Android webview 应用程序和 Google Analytics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!