A User Agent string is a line of text providing the web server with information on the device requesting a website triggering the server to select and send the suitable content. This information is crucial in making sure that the websites are rendered properly on every browser and every device. Read on to learn more on how to do User Agent string analysis.
Why User Agent string analysis is difficult
Software makers have often concealed the truth about the device or the browser to improve the user experience and meet marketing goals. In some cases the User Agent string conveys information which isn’t true for the requesting device, such as in the following example:
Although this UA comes from a Windows 7-based laptop using a Chrome browser, it contains keywords such as ‘Mozilla’, and ‘Safari’.
User Agent spoofing
The technique of User Agents' masquerading started in the very early days of Internet browsing. Have a look at the following user agent strings originating from the mid-1990s:
- Netscape Navigator 2: Mozilla/Version [Language] (Platform; Encryption)
- Internet Explorer 3: Mozilla/2.0 (compatible; MSIE Version; Operating System)
Netscape Navigator 2, codenamed Mozilla, was the dominant browser back then offering more features than IE 3. Instead of adjusting websites to IE’s limited capabilities, web developers often blocked users completely.
In response to this Microsoft made the decision that the early version of Internet Explorer would introduce itself as Mozilla to ensure end-users could view the content and to help the new browser grow its market share.
Interestingly, some parts of the User Agents used back in the days of web browsers are still present. As a case in point, take a look at the brief analysis of the modern User Agent mentioned earlier.
User Agents for mobile devices also convey misleading information. Here is one of the User Agents sent by the Palm Pre’s browser, one of the early smartphones which competed with the iPhone 3G and 3GS back in 2009.
The Palm Pre’s makers included the keyword ‘iphone’ in the device’s User Agent. This masquerading technique was supposed to ensure that the Palm Pre’s users could access online services that might otherwise be unavailable.
Device detection must be based on User Agent strings and other HTTP headers
A device-aware content adaptation strategy including smartphones and tablets requires device detection to be carried out by doing some analysis of the User Agent string.
Although searching for keywords in User Agents can look like a reasonable approach to device detection, it certainly won’t return any accurate results for the reasons explained earlier in this article.
For example a User Agent string that contains the keyword 'iphone' doesn't necessarily mean the requesting device is really an iPhone. To accurately detect a device you need to analyse every aspect of the user-agent as well as other HTTP headers, and not just keywords. This is especially important if you require some fine-grained targeting, such as language and locale.
This is why sophisticated device detection solutions, such as DeviceAtlas, are utilized to ensure accuracy and speed of detection.
You can test DeviceAtlas’ capabilities by following the steps below.
Search online for User Agent string examples, or search for any device using our Device Browser (e.g. iPhone 6) and copy its User Agent (you can find it at the bottom of the device page – create a an account to do this).
- Head over to the User-Agent Tester and paste the User Agent string. Click the result to find out what DeviceAtlas says about the selected device.
Try pasting more User Agent strings to check the User-Agent Tester and learn about the DeviceAtlas’ accuracy.
Get started with a local device detection trial
DeviceAtlas is a high-speed device detection solution used by some of the largest companies in the online space to:
- Optimize UX and conversion rate on mobile
- Boost web performance
- Target ads and analyze web traffic
- Enable App analytics and advertising insights
Get started with a locally-installed trial to test DeviceAtlas at no cost.