简体   繁体   English

Android Webview应用程序和Google Analytics(分析)

[英]Android webview app and 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. 我有一个简单的本地Android应用程序,它是网站的Webview,可以有效地使移动设备就绪的网站像本地一样。 The website already has Google Analytics installed. 该网站已经安装了Google Analytics(分析)。

What might be a good way to track which visitors are using the app? 跟踪哪些访客正在使用该应用程序的好方法是什么?

  • I could adding Android Native App Tracking , but I presume that would double track the users. 我可以添加Android Native App Tracking ,但是我认为这将对用户进行两次跟踪。 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. 我可以将自定义get变量传递给网站,该网站可能会向本机应用程序用户的跟踪添加自定义属性 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. 我觉得我想必有一个明显的答案。

that should help you: 这应该可以帮助您:

Now getting back to the Analytics tracking of this web app, I used the code provided by Google here. 现在回到此Web应用程序的Google Analytics(分析)跟踪,我在这里使用了Google提供的代码。 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 http://www.the4thdimension.net/2011/11/using-google-analytics-with-html5-or.html

And in stats of google analytics you should get some info at least about operating system android. 在Google Analytics(分析)的统计数据中,您至少应该获得一些有关Android操作系统的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM