A user agent is what identifies a browser and its operating system to the webserver – the bridging software between a user and web. Every browser contains a unique user agent field in its HTTP header that differentiates it from other browsers when it connects to the web.
We can understand the name “user agent” better if we go back a little in time, to when the internet was evolving. When the internet was a system grounded on text, users needed commands to surf and message each other. The difference is that users now rely on browsers to do all the hard work. All they have to do is point and click for the browser to go to work as an ‘agent’ that turns actions into commands. When a browser (or a comparable device) loads a website, it presents itself as an agent as it fetches the requested information.
The user agent request header gets sent with each request the browser makes to a website. The user agent is used to enable servers and network peers to figure out the operating system, application, vendor, and/ version of the requesting user agent. There is a lot of information about the device and network it’s on, alongside what is requested. It’s the data meant for web developers. It enables them to customize the user experience according to the user agent that loads the web page.
There is no typical way of writing a user agent string, and that’s why they vary from browser to browser, with many jamming them with tonnes of information. Many sites have even dedicated themselves to shedding light on the information that user-agent strings are trying to convey. Otherwise, the webserver needs this information to present different web pages to varying browsers and operating systems. It is how mobile pages are sent to mobile devices, with adjustments to suit versions and updates. Browser market share statistics are primarily based on collected user agent data.