UserAgent.me

What Does Your User Agent Say About You?

Archive

A user agent is a computer program representing a person, for example, a browser in a Web context.

Besides a browser, a user agent could be a bot scraping webpages, a download manager, or another app accessing the Web. Along with each request they make to the server, browsers include a self-identifying User-Agent HTTP header called a user agent (UA) string. This string often identifies the browser, its version number, and its host operating system.

Spam bots, download managers, and some browsers often send a fake UA string to announce themselves as a different client. This is known as user agent spoofing.

The user agent string can be accessed with JavaScript on the client side using the navigator.userAgent property.

A typical user agent string looks like this: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0".

(Source: Mozilla.org)

User Agent String

Browser Data

User Agent Parsing

author
Brent Mccoy
• Monday, 16 November, 2020
• 11 min read

In summary, it is not a very standardized format, and as we will see, has evolved into a fairly chaotic environment that can be only unraveled by sustained and dedicated attention to mapping and interpreting this entropy. One of the main use cases of an user agent parser is to identify and handle requests from certain types of traffic.

agent user parser wurfl detection
(Source: www.scientiamobile.com)

Contents

This is particularly useful when dealing with the wide spectrum of devices in use today, and allows you to get as fine-grained as you like with your content targeting strategy. Outside of web optimization, this has obvious applications to the advertising sector, where the device can be useful as a criterion for targeting.

Bots and crawlers have User -Agents too, and can be identified accurately by a good device detection solution. Security is the other big area where being aware of the nature of traffic hitting your services is extremely important.

These range from search engines to link checkers, SEO tools, feed readers, scripts and other nefarious actors at large in the web landscape. Being able to distinguish between these different sources can provide significant savings in IT costs by detecting and identifying bot traffic to your site.

You would need to constantly update your regex rules as new devices, browsers and OSs are released, and then run tests to see if the solution still works well. At some point, this becomes a costly maintenance job, and, over time, a real risk that you are misdirecting or failing to detect much of your traffic. Accurately parsingUser -Agents is one problem.

Some approaches hog server resources because of their unsophisticated and messy APIs and codebases. Device Atlas uses a Patricia train data structure to determine the properties of a device in the quickest and most efficient way.

(Source: www.youtube.com)

This is the reason why major companies rely on established solutions built on proven and patented technology like Device Atlas. If only a single parsing target is required it can be passed a string parameter.

The function implementation is built on regex checks of the input string against a huge number of predefined patterns. When the function is used in a query, make sure it runs in a distributed manner on multiple machines.

Due to the rich information they contain, UAS can also serve as a source of data for Machine Learning applications. Here I address this issue and discuss an efficient way to create informative features from UAS for Machine Learning models.

Having UAS-based proxies for such characteristics can be particularly valuable when no other demographic information is available for a user (e.g. when a new, unidentified person visits a website). In some cases, this is straightforward to do as automated web crawlers use a simplified UAS format that includes the word “bot” (e.g., Google bot/2.1 (+http://www.google.com/bot.html)).

However, some crawlers do not follow this convention (e.g., Facebook bots contain the facebookexternalhit word in their UAS), and identifying them requires a lookup dictionary. This approach can work well in simple cases when only high-level and readily identifiable UAS elements need transforming into features.

detection device
(Source: www.youtube.com)

Moreover, new devices and versions of operating systems and browsers emerge every day, turning the maintenance of high-quality parsers into a formidable task. To overcome these challenges, one can apply a dimensionality reduction technique and represent UAS as vectors of fixed size, while minimizing the loss of original information.

This idea is not new, of course, and as UAS are simply strings of text, this can be achieved using a variety of methods for Natural Language Processing. In my projects, I have often found that the fastest algorithm developed by researchers from Facebook (Bojanowski et al. 2016) produces particularly useful solutions.

However, arguably the simplest way to train and use fastest models in R is by calling the official Python bindings via the reticulated package. Data are stored in a plain text file, where each row contains a single UAS.

Of course, one way to test it would involve plugging the vector representations of UAS obtained with that model into a downstream Machine Learning task and evaluating the quality of the resultant solution. Points were colour-coded according to the Sergeant ’s hardware type. Figure 4 shows a 3D tone plot of embeddings calculated for UAS from a test set using the fastest model specified above.

Labels formatted this way (and potentially separated by a space in the case of a multi label model) are to be prepended to each document in the training dataset. We can evaluate the resultant supervised model by calculating precision, recall and f1 score on a labelled test set.

agent parsing strings usage ie
(Source: www.xplenty.com)

Visual inspection of the tone plot for this supervised model also confirms its high quality: we can see a clear separation of the test cases in regard to the hardware type (Figure 6). This is not surprising as by training a supervised model we provide supporting information that helps the algorithm to create task-specific embeddings.

A 3D tone visualization of embeddings obtained with a fastest model trained in a supervised mode, with labels corresponding to the hardware type. This article has demonstrated that the rich information contained in UAS can be efficiently represented using low-dimensional embeddings.

In fact, browser makers and device manufacturers are free to conceal some important information or even build nonsensical UAS. The information included in the UA can’t be analyzed simply by searching for keywords because it will return inaccurate results.

This works especially well for high-traffic, high-profile websites and other online services such as ad platforms or web analytics tools. Some of the largest businesses avoid any dependency on cloud services, and thus utilize locally installed device detection platform.

In Device Atlas’s case, the device data is available in a highly compressed JSON format minimizing the server footprint. The data file consists of a JSON structure offering extremely fast lookups with a minimal footprint.

agent strings parsing
(Source: www.xplenty.com)

Making statements based on opinion; back them up with references or personal experience. The target of this package is to make it less painful, by providing an abstract layer for many user agent parsers.

HTTP's providers are simple to use, since you need only an API key to get started. Here is a comparison matrix, with many analyzed Sergeant strings, to help you device which provider fits your needs.

WebKit (18,642,786) Blink (9,913,314) Trident (1,737,329) Presto (368,303) Gecko (299,203) Edge HTML (25,016) Gonna (3,639) HTML (3,483) Seafront (3,419) If you need to integrate the user agent parser directly into your website or system then it's very simple to use the API.

Other Articles You Might Be Interested In

01: Free Download User Agent Switcher For Firefox
02: Ipad Browser Change User Agent
03: Iphone 11 Pro Max User Agent
04: Iphone Xs Max Useragent
05: Ios 12 User Agent String
06: Ios 13 Safari User Agent
Sources
1 developer.apple.com - https://developer.apple.com/forums/thread/119186
2 www.whatismybrowser.com - https://www.whatismybrowser.com/guides/the-latest-user-agent/safari
3 stackoverflow.com - https://stackoverflow.com/questions/58019463/how-to-detect-device-name-in-safari-on-ios-13-while-it-doesnt-show-the-correct
4 developers.whatismybrowser.com - https://developers.whatismybrowser.com/useragents/explore/software_name/safari/
5 webkit.org - https://webkit.org/blog/9674/new-webkit-features-in-safari-13/
6 www.idownloadblog.com - https://www.idownloadblog.com/2019/06/10/ipados-overview-safari/
7 github.com - https://github.com/serbanghita/Mobile-Detect/issues/795
8 deviceatlas.com - https://deviceatlas.com/blog/mobile-browser-user-agent-strings
9 www.scientiamobile.com - https://www.scientiamobile.com/detect-ipados-13/