Updated on 27. December 2022 by Jan Bunk
Just like you might be interested in seeing how users interact with your website, you might want to know how they use your app. You can do so by taking a look at your website analytics.
The easiest way to separate website users from app users in your analytics is by filtering the user agents. The user agent is a short string that the browser sends to websites. The user agent contains information about the browser, for example a Firefox browser could send something like this user agent:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0The app uses a few different user agents:
$version is the internal version of the app (e.g. 1.4.8+52) and $operatingSystem is the platform the app is being used on (e.g. ios or android).
$regularUserAgent is the user agent of a mobile browser that would be expected from the device, like Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
You don't really need to worry about all of this, unless you want to do something special. Otherwise, just follow the next steps to filter by the user agent in your analytics.
As an example, this is how to filter by user agent in Google Analytics:
A more complicated but also more powerful way of detecting whether a user is visiting your website with a browser or the app is with the help of JavaScript. This is especially useful if your analytics software does not support filtering by user agents.
The easiest option is using getAppPlatform
from the app helper script.
The function returns null if the app is opened in the browser, otherwise the operating system the app is used on. However, as mentioned in its documentation, this only works if you let the app modify user agents.
An option that doesn't rely on user agents is executeWhenAppReady
. The code inside it will only be executed if your website is being viewed inside the app.
Related Articles
When, Why, and How to Update Your App
In this article we'll take a look at when you have to submit an update to the app stores, when you can do it optionally and what benefits that has. We'll also talk about the recommended update frequency and how to actually publish an app update.
Export Compliance in the App Store & Play Store
You need to pay attention to some export regulations because apps count as encryption software and app downloads count as exporting the app from the USA.
How to generate keys & keystores and use them to sign your appbundle. Afterwards verify it and upload it to the Play Console.
Hi, I'm Jan! I created webtoapp.design in 2019 while studying computer science in university. A lot has changed since then - not only have I graduated, but it's also no longer just me running webtoapp.design. We've grown to a global, fully remote team and have gathered lots of experience around app development and app publishing. We've created and published hundreds of apps in the app stores, where they've been downloaded hundreds of thousands of times.