Android webview app and Google Analytics
that should help you:
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
And in stats of google analytics you should get some info at least about operating system android.
Related videos on Youtube
Sir.Nathan Stassen
You can find me working with PHP, JavaScript, jQuery, BackBone.js, PowerShell, VBS, or just with a backpack in the wilderness. #SOreadytohelp
Updated on July 12, 2022Comments
-
Sir.Nathan Stassen almost 2 years
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.
-
Sir.Nathan Stassen over 10 yearsIn the analytics I'm looking to be able to distiguish between android webview app vs. mobile web browsers users.
-
RoggA over 9 yearsI'm using the same set-up as Sir.Nathan Stassen with google analytics implmented on the actual webapge. I get stats from my app users like they're using defalt browser and a mobile operating system. that's good. But I miss the demographics data a user would report from their standardbrowser. Age/Gender and interests. Would your solution solve this?
-
Maher Abuthraa about 9 yearsTo enable Remarketing, Demographics & Interests reports you should firstly enable Advertising Features see : developers.google.com/analytics/devguides/collection/android/v4/…