A user agent (short: UA) is software that communicates with servers in a network. An example would be a web browser that retrieves a web page from a server on the internet and displays it. The user agent acts as a mediator between the user and the web server just like a human agent. It processes the user's instructions, transfers them and receives the requested data. The user agent transmits information such as the browser version, installed plugins, and other data to the web server. Based on this data, the server can assess the capabilities of the user agent and deliver the appropriate data to it.
Transmitting the user agent through the HTTP header
The information that identifies the user agent is transferred to the web server in the HTTP request header. Each header contains a characteristic string that servers can use to identify the application type, operating system, software vendor, or software version of the requesting user agent.
The structure and content of this information are not standardized. Each developer can insert and submit his own information. For example, the basic syntax for a Firefox web browser is:
Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion
Mozilla/5.0 is a general token stating the web browser is compatible with Mozilla. Modern browsers use this token for historical reasons only, since it is no longer of great importance.
platform describes the native platform the web browser operates on - for example, Windows, Mac, Linux or Android and whether it is a mobile phone or not. Firefox OS for mobile simply puts the word "Mobile" here.
rv:geckoversion indicates the version of Gecko. Gecko is an HTML rendering engine that web browsers use to display a web page. In current browsers, geckoversion is the same as firefoxversion.
Gecko/geckotrail indicates that the browser is based on Gecko. On desktop, geckotrail has the fixed string "20100101".
Firefox/firefoxversion indicates the browser is a Firefox version with the specified version number.
An example of a Firefox browser on a desktop operating on Windows would look like this:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
Information provided by the agent can be modified or falsified. One example would be some mobile web browsers, which can switch between mobile or desktop mode to get access to websites that only allow desktop computers. In the early days of the internet, Microsoft's first Internet Explorer pretended to be a Netscape browser to access web pages designed for Netscape Navigator, the dominant browser on the market back then.
Types of user agents
Browsers like Mozilla Firefox, Google’s Chrome as well as Safari and Opera are examples of user agents. However, other applications can also act as user agents. Examples are:
- Crawlers: Googlebot, Yahoo! Slurp, MSN bot
- Game consoles: PlayStation, Wii, PlayStation Portable and Bunjalloo (the browser on the Nintendo DS)
- Legacy operating systems: AmigaVoyager
- Link checkers: e.g. W3C-Checklink
- SEO tools / on-page crawlers: e.g. SeobilityBot
- Web applications: Flash Player, Adobe Acrobat Reader, feed readers, screen readers, validators, media players, streaming portals
Not all user agents are controlled or instructed by humans. Search engine crawlers are an example of user agents that visit websites automatically.
Importance of user agents
When an application receives content tailored to its user agent, this process is referred to as agent name delivery. Search engine optimization uses this process to present different content to search engine bots compared to real visitors’ user agents. When this black hat SEO tactic referred to as cloaking is used, visitors see a web page optimized for humans whereas crawlers access content and structure that is mostly simple and optimized for high rankings in search results. However, search engines know this spam technique and therefore often act as browsers.