User Agent String is a string value associated with a web browser that specifies its browser type, version, Operating system (OS) version and other relevant information and you can change user agent string as needed on your browser. This information is send to the web server when the web browser makes a request for a page or content.
This information is extremely useful to the server, as it allows to serve or send back content in the most suitable format for the machine and browser you are using. The most recognizable use of this information is when mobile smart phones like iPhone and Android can be served a different layout or a mobile friendly website than a desktop. Thus a web browser running on a desktop or tablet will see an entirely different site or content laid out differently than the mobile version.
Examples of user agent strings
- Mozilla Firefox: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20130724 Firefox/24.0
- Google Chrome: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1585.0 Safari/537.36
- Microsoft IE : Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0
By changing the user agent string, you are effectively spoofing or tricking the server into believing that you are using an entirely different web browser in a different operating system. Usually there is no need for this value to be tweaked as most “well designed” websites will cater all the web browsers correctly. Still, there may be conditions and various reasons as to why you want to do this
- Some websites impose restrictions on the web browsers that can be used. Some bank websites even test for exact versions of supported browsers.
- Some browsers does not support browsers that are not very popular such as IceWeasel, Galeon, Konqueror etc and worse, treat them as text browsers.
- If you are developing a website, then this is a quick and easy way to test. It is not however a good substitute for testing with an actual instance and version of the browser.
For Mozilla Firefox, there are several add-ons available that will easily allow you to change user agent string on the fly. Some of the popular ones are
UAControl : A highly rated plugin which is pretty simple to use. It provides the ability to specify user agent strings on a per-domain basis.
User Agent Switcher: Another simple addon that allows you to change the user agent quickly using either a menu item and/or a toolbar button.
User Agent Overrider : This addon allows you to change the user agent string from a toolbar button. This however does not have support for domains, hence will update it globally.
You can find even more plugins by doing a search in Firefox add-ons site. Most of the addons provide very similar functionality, so go with one with good rating and works best with your version of Firefox.
Firefox provides an config option to change user agent string. Changing the string through configuration with the steps mentioned below will change the user agent of the browser quasi-permanently unless you change it back. This will be the user agent used across all web domains. So, this usually not a desirable thing to do unless you have a very strong reason for it.
If you like to use custom user agents for only certain web domains then you might be better of using one of the addons mentioned above or refer to the section immediately below this.
It is not easy to get to change the configuration, as there is no good user interface to do this. You can access this config property from within the config editor in Firefox. Follow the steps below to modify using the config editor.
- Type the URL about:config in the URL location bar.
- Type general.useragent.override in the search bar at the top of the page to filter the entries
- Create a new entry if you cannot find one.
- Right click anywhere inside the panel and select New -> String
- Type in general.useragent.override as the name and click OK
- Type in the desired user agent string as the value in the next popup and Click OK
- If the property already exists, then double click on the value field and enter the desired user agent in the popup and click OK
- Test the user agent string using your preferred method. (Some mentioned below)
Using Config per Domain
You can use the same method described in the section above to change user agent string on a per-domain basis. In order to change the user agent for an example domain named mywebsite.com, follow the steps below…
- Type URL about:config in the URL location bar
- Type general.useragent.site_specific_overrides in the search at the top to filter the entries
- Set or ensure that the value of this property is true
- Right click anywhere in the panel and select New->String
- Type in general.useragent.override.mywebsite.com as the name and click OK (substitute the actual domain you need in the name)
- Type in the desired user agent string as the value and click OK
- Test the user agent string
You can have as many config properties as needed. Remember to substitute the correct domain name in each of the property name. The generic property name is general.useragent.override.[domian name].
If for some reason you cannot or don’t want to use the about:config editor, then you can specify these values in either the pref.js or user_pref.js files. You should be able to find these files inside your firefox profile folder.
Be sure to close and shutdown the Firefox browser first.
- Close the Firefox browser
- Using a file browser or command line, find the file named pref.js (or user_pref.js) inside the Firefox profile folder.
- Open the file in a text editor
- Insert the code user_pref(“general.useragent.override”,”Some user agent string”); into the file
- Save the file
- Restart Firefox
Check the changed User Agent
Once you have set or modified the user agent in the browser, you might want to make sure that this has been set correctly. This is only important if you have set the user agent globally using the config or have it set across all domains. If you just changed it for just one or two specific web domains, then there is really no good to test for it.
Whatever the reason for changing the user agent string, you may want to it remember the fact that you did change it and that it is not set to the default. Otherwise, you might be troubleshooting for a long time when some website functionality does not work correctly which might otherwise have worked with the default user agent. Use this sparingly …