What is User Agent? | Seletronic
Ofertas Resgatar Cupons

What is User Agent?

Understand how this small piece of text is responsible for improving the internet and for many other purposes

- 5 min de leitura
What is User Agent?
Google News Telegram

User Agent is a request header string that allows servers to identify any browser, application, operating system and other important information of those who made a request to the server. Being a string, this means that this information is plain text characters.

What is the User Agent for?

The User Agent is used by the server to send a correct response to the requester, for example, if you use the Google Chrome browser on your computer with Windows 10 operating system, when accessing a website, this information is passed by the User Agent together with your browser version. In this way, the server can send a page correctly adapted to your browser so that it works correctly. This is an example of a User Agent for a Google Chrome browser on the Windows 7 64-bit system:

Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36

The same is true if you make a request via a mobile browser, where the server can identify that you have made a page request via a mobile device, by sending a page in the correct format to mobile phones, specifically for your mobile phone model . This is an example of a user agent for a Google Chrome browser on a Motorola Android phone model Moto G7 Power:

Mozilla/5.0 (Linux; Android 10; moto g(7) power) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.210 Mobile Safari/537.36

Apps and bots also have a user agent

Applications and bots also have their own User Agent to be correctly identified by the servers. For example, when sending a link through WhatsApp, the application sends its own User Agent to the server where the server can modify the page to provide information to the WhatsApp application.

The famous web crawler bots also have their own User Agent. For example, when Google visits a website to index a page, it uses a User Agent called Googlebot, which allows the server to identify that it was Google that went through that page. The same thing happens with other crawlers like Bing, Yandex and others.

In the case of most applications, the User Agent is sent along with the version of the application, and in the case of bots the name of the bot is sent along with the version of this web crawler.

List of common user agents

Application agents like WhatsApp, Facebook and Google, Bing and other web crawlers are often the same or change little. What is usually modified in these agents is only the version number. Based on this, we created the following table with the most popular User Agents:

Nome User Agent
Facebook facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
WhatsApp iOS (iPhone) WhatsApp/2.21.60.16 i
WhatsApp Android WhatsApp/2.21.6.17 A
Googlebot Desktop Googlebot/2.1 (+http://www.google.com/bot.html)
Googlebot Mobile DoCoMo/2.0 N905i(c100;TB;W24H16) (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)
Googlebot de Imagens Googlebot-Image/1.0
Googlebot do Google News Googlebot-News
Googlebot para videos Googlebot-Video/1.0
Pinterest Pinterest/0.2 (+https://www.pinterest.com/bot.html)
Telegram TelegramBot (like TwitterBot)

The User Agent can be easily changed

Since the User Agent is sent by our own device and can be changed from application to application, it is very easy to be manipulated, allowing us to place an order on the server with the User Agent we want.

Some computer browsers focused on website development have the option of emulating a User Agent defined or customized by the user with the intention of testing how a web page will be delivered for each type of device. Google Chrome, for example, has several predefined User Agents so that we can perform server response tests by emulating cell phones of different brands:

Using server programming, it is also possible to request a response from another server or from the server itself using a fake User Agent. Below is a PHP code that requests a website with a fake user agent:



$userAgent = ‘WhatsApp/2.20.112 A’;

$url = ‘https://site.com/’;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);

$resposta = curl_exec($ch);

The value of the $ userAgent variable in the code above can be easily changed by any of the User Agents shown in the table of common User Agents.

How the user agent can be used to improve SEO and the user experience

The User Agent can be used intelligently to improve SEO and the user experience. As it is possible to identify the User Agent of a device when it accesses our server, we can, based on this string, know if the user of the site is accessing via cell phone or computer, and based on this information, send a lighter page to devices mobile, taking into account that they tend to have less processing power than a computer.

By identifying the operating system of the user’s device, we can also offer a personalized experience for those who access the website, offering content that is more relevant to the device in question.

Let’s say you have an application and game download site and a visitor accesses the Windows downloads page through an Android phone. In this case, using the user agent and knowing the user’s operating system, we can offer the user access to the part of the website that contains applications and games for the Android system.

How the User Agent is used to deceive users with fake messages

As every time we use the internet browser the User Agent is sent to the server of the website we are accessing, some companies or people use it to deceive the user with false alert messages, saying that the cell phone has been infected and that it is necessary download some program to fix this. And using the user agent, they can tell you exactly what make and model of your phone to make the fake virus message even more real.

Marcus é o fundador da Seletronic. Além disso, é programador, e editor no site. Ama ajudar as pessoas a resolverem problemas com tecnologia, por isso criou esse site. Segundo ele: "A tecnologia foi feita para facilitar a vida das pessoas, então devemos ensinar a usá-la". Apesar de respirar tecnologia, ama plantas, animais exóticos e cozinhar.
Menu Explore o conteúdo!
Dark Mode