3

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?

  • 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.

4

1 回答 1

2

这应该可以帮助您:

现在回到这个网络应用程序的分析跟踪,我在这里使用了谷歌提供的代码。所以代码变得有点像这样。

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 的信息。

于 2013-08-01T10:01:06.263 回答