1. SEO Wiki
  2. User agent

User agent

"User Agent" Definition

A user agent is a string of text that is sent by a web browser to a web server to identify itself and provide information about the browser's capabilities. The User Agent string can include information such as the browser type and version, the operating system, and the device type.[1]

What is User Agent used for?

Web servers use the User Agent string to determine how to serve content to the browser. For example, a web server may use the information provided in the user agent string to serve a different version of a website to a mobile device than it would to a desktop computer.

The user agent is transmitted to a web server through the HTTP header of a request made by a web browser.

When a web browser makes a request to a web server (for example, to load a web page), it sends an HTTP request message to the server. This message includes an HTTP header, which contains a variety of information about the request. One of the pieces of information in the HTTP header is the user agent string.

Here is an example of an HTTP request message with the user agent string in the HTTP header:

GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36

In this example, the user agent string is Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36.

The web server receives the HTTP request message and reads the HTTP header, including the user agent string. It can then use this information to determine how to serve content to the browser.

Types of User Agents

There are many different types of User Agents, including:

  • Web browsers: These are the most common type of user agents. Examples include Google Chrome, Mozilla Firefox, and Microsoft Edge.
  • Mobile apps: Many mobile apps act as user agents, making requests to servers and displaying the responses to the user.
  • Desktop applications: Some desktop applications, such as email clients and chat clients, act as user agents when they communicate with servers.
  • Bots and crawlers: These are automated user agents that are often used for tasks such as web indexing[2], site monitoring, and data mining.
  • Internet of Things (IoT) devices: These are user agents that represent devices connected to the Internet, such as smart thermostats, security cameras, and home appliances.
  • Custom user agents: Some user agents are designed specifically for a particular purpose and are not generally available to the public. For example, a company might develop a user agent to perform automated testing of its website.
     
    user agent settings in Rank Tracker

    The image above shows how you can set up custom user agents to control rank tracking in the Rank Tracker tool[3].

How to find my user agent in a browser?

Here’s how you can check and get the user agent using your browser’s console:

  1. Open the developer tools in Google Chrome, Microsoft Edge, Mozilla Firefox, Safari or any other browser. You can use F12 or Ctrl+Shift+I on Windows/Linux, or Cmd+Option(⌘)+I on macOS.
  2. Switch to the Console tab.
  3. Type navigator.userAgent in the console and press Enter (or Ctrl+Enter). The console will return a string which is your browser’s user agent.

Remember, it’s generally not recommended to use user agent to detect the browser for serving different web pages or services. Instead, consider using feature detection, which checks if the specific feature you need is available. This approach is more robust and future-proof.

Please note that it’s possible to change or “fake” what your web browser sends as its User Agent. Some browsers let you change this setting, affecting what’s known as “Mobile Mode” or "Desktop Mode". However, changing your user agent should be done with caution as it can affect how websites are displayed and function.

How to switch my user agent in a browser?

Changing your browser’s user agent can be done in a few steps. Here’s how you can do it for different browsers:

How to change user agent in Google Chrome & Microsoft Edge:

  1. User agent switcher is part of its Developer Tools. Open them by clicking the menu button and selecting More Tools > Developer Tools. You can also right-click anywhere on a webpage and select Inspect, or use F12 or Ctrl+Shift+I on Windows, or Cmd+Option(⌘)+I on Mac.
  2. Choose More Tools > Network Conditions by clicking on the three vertical dots on the upper right corner.
  3. Uncheck the Select Automatically checkbox.
  4. Choose one from the built-in User-Agents list or enter any string you want in the field below the list.

How to switch user agent in Mozilla Firefox:

  1. Type about:config into Firefox’s address bar and press Enter.
  2. Right-click on the about:config page, point to New, and select String.
  3. Name the preference general.useragent.override.
  4. Enter your desired user agent as the value of the preference.

How to change user agent in Safari:

  1. Go to Preferences.
  2. Enable Develop Menu Bar by going to Advanced and checking Show Develop menu in menu bar.
  3. Navigate to Develop > User-Agent. You can select from a predefined list or enter a custom user-agent string by choosing Other...

Please note that changing your user agent should be done with caution as it can affect how websites are displayed and function. Also, these settings are temporary and only apply while you have the Developer Tools pane open, and it only applies to the current tab.

Examples of User Agents

Here are some examples of user agents for different devices and browsers:

Desktop Browsers

Microsoft Edge on Windows:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0

Google Chrome on Mac OS X:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Google Chrome on Windows:

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

Mozilla Firefox on Windows:

Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0

Mobile Apple Devices

Safari on iPhone (iOS) and iPad (iPadOS):

Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1
Mozilla/5.0 (iPad; CPU OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1

Mobile Android Devices

Chrome on Android:

Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36

Samsung Galaxy S22 5G:

Mozilla/5.0 (Linux; Android 13; SM-S901B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36

Please note that these are just examples and the actual User Agent string can vary based on the specific version of the browser and the operating system. 

Importance

User agents play a crucial role in the way the World Wide Web functions, as they enable users to access and interact with online content and services. Some of the key benefits and importance of user agents include:

  • Interoperability: User agents enable different devices, platforms, and software to communicate with each other and access the same online content and services.
  • Accessibility: User agents enable users with disabilities to access the web by providing features such as text-to-speech, screen magnification, and keyboard navigation.
  • Personalization: User agents can store user preferences and settings, such as language and display options, which allow for a more personalized web experience.
  • Security: User agents can implement security measures, such as SSL/TLS encryption and certificate verification, to protect user data and prevent malicious attacks.
  • Innovation: User agents enable the development of new and innovative technologies, such as virtual and augmented reality, which can enhance the user experience.

Overall, user agents are an essential component of the web ecosystem, enabling users to access and interact with online content and services in a convenient and secure manner.

How Google Crawler Works: SEO Starter-Pack Guide