Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Tips and Tricks / User Agent String

User Agent String

A very short description of how a user can change the User Agent String reported by Mozilla based browsers including Firefox™.

Disclaimer

All Tips and Tricks and HOWTOs on this website are provided as-is for information purposes. Any alterations you make to your system is entirely your own responsibility. Crann Tara cannot be held responsible for any consequential loss or damage to your system caused by using any of the following information.

We strongly suggest you make a backup of your system and/or settings prior to making any adjustments.

All trademarks mentioned are owned by their owners and their use, on this website, does not affect their validity. The use of brand names, trademarks or website names should not be seen as an endorsement or criticism.

Introduction

User Agent Strings are typically used to identify an agent type, agent version number and sometimes the computer platform the agent runs on. Agents are computer applications used to access content online - which may be the internet, an intranet or perhaps just on your own computer. The most common Agents are internet browsers, such as, Mozilla Firefox™, but may also be FTP clients, download managers, RSS readers and even search engine spiders.

Use of an User Agent String is not compulsory although some webmasters may setup their websites to require you to provide one. As all browsers are not the same the way in which they display the page contents can differ quite dramatically. In consequence, webmasters often provide different content for different browsers based on the information provided by the agent string. There isn't, however, any means to truly authenticate an agent string so, so called, agent string spoofing is relatively easy and straightforward.

Reasons for changing the User Agent String

There are many reasons why you might want to change your agent string. As mentioned above webmasters may require the supply of an agent string and then not provide a fall back postion should your agent string not be specifically listed. You can then get around this poor design by instead supplying a common agent string.

If you are creating different content for different browsers you may want to test your own setup without having to go to the trouble of really changing computers and browsers to see the results.

As user agent strings are typically recorded in webserver logs you may want to change your browsers' string so that you can exclude yourself from your own website usage statistics.

Determining your own Agent String

If you are using a Mozilla derived browser either select Help/About or enter the following into your address bar

about:

Once you have done this you should see a pop-up window which looks similar to the following screenshot.

Browser About Dialog
A typical browser about dialog window

From the last three lines, in the image above, we can tell that the browser concerned is derived from Mozilla, it is using the X11 windowing environment, running on the GNU/Linux platform, using the language and encoding English GB, that the browser is called IceWeasel running on the Debian™ distribution.

If you want to discover much more information about your own agent string and what the text means you can visit the site useragentstring.com

Changing the Agent String manually

With Mozilla (including Firefox) and derived browsers you can add a line in your user.js1 file which will overide the agent string setting in the prefs.js file.

  • Before making any changes you should close your browser.
  • Unless you have previously created a user.js file it is likely it won't exist and will need to be created.
  • The location of the user.js file differs depending on the Mozilla browser type you use and on which platform. On Linux™ and UNIX™ type platforms the location will be something like:
  • /home/<username>/.mozilla/firefox/<random string>.default/

    or

    /home/<username>/.mozilla/default/<random string>/

    You will need to substitute <username> with your name and <random string> with the random string created for your installation. If you have created more than one browser profile you will have multiple directories.

    If you use Microsoft Windows 95/98/Me it should be something like (note - depending on your text size the code may be displayed inside a scroll box , so as not to break the page format):

     

    C:\WINDOWS\Application Data\Mozilla\Firefox\Profiles\default.<random string>\
    If you use Microsoft Windows 2000/XP it is probably something like (note - depending on your text size the code may be displayed inside a scroll box , so as not to break the page format):

     

     

    C:\Documents and Settings\<username>\Application Data\Mozilla\Firefox\Profiles\

     

    Again, you will need to substitute <username> with your name and <random string> with the random string created for your installation. If you have created more than one browser profile you will have multiple directories. By default these folders are hidden and viewing needs to be enabled.

    If you use Microsoft Vista it is probably something like:

     

    C:\Users\<user name>\AppData\Roaming

     

    Now that you have located the proper location and, if neccessary created, the user.js file you can now enter a new agent string. There are many websites on the internet listing user agent strings which you can use. For an example we will just use the following agent string (note - depending on your text size the code may be displayed inside a scroll box , so as not to break the page format):

     

    Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1.6) Gecko/20070914 Firefox/2.0.0.7

     

  • To make the change open your user.js file using a text editor (not word processor) and on a line of its own add the following (note - depending on your text size the code may be displayed inside a scroll box , so as not to break the page format):
  • user_pref("general.useragent.override", "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1.6) Gecko/20070914 Firefox/2.0.0.7");
  • Start your browser and check the change has worked by opening:
  • about:

Changing the Agent String via the GUI

The above method will change your user agent string but it is a little cumbersome if you want to change it on a regular basis. This is where one of the hundreds of Firefox™ add-ons makes life much easier. User Agent Switcher adds a menu item under Tools which allows you to switch between various user agent strings. You can add as many agent strings to the switcher as you like and still go back to the default original whenever you want. Installation instructions can be found at the User Agent Switcher homepage.

The following screenshot shows User Agent Switcher in operation:

User Agent Switcher
Screen capture showing User Agent Switcher dialogs


1 There are, at least, a couple of alternative ways of making this change including editing the prefs.js file and using about:config from the browser. However, using the user.js method is probably safest as you can return to a default configuration by removing this file should things go wrong.

References -

http://kb.mozillazine.org/Firefox_:_FAQs_:_About:config_Entries

http://kb.mozillazine.org/Profile_folder

 

The Firefox logo and Firefox are registered trademarks of the Mozilla Corporation.

Debian is a registered trademark of Software in the Public Interest Inc.

Windows 98/Me/2000/XP/Vista are registered trademarks of Microsoft Corporation.