User Agent String HOWTO

This HOWTO is 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.

Iceweasel about screen

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.js 1 file which will overide the agent string setting in the prefs.js file.

/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

Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1.6) Gecko/20070914 Firefox/2.0.0.7
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");

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


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.

W3C CSS Validator W3C Validator Level Double-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0 txt2tags homepage