Geolocation Code in Webpages
Created | Updated Nov 24, 2013
Just to let you know, I'm no longer updating this page. Please refer to the Edited Entry - Alex Ashman. |
Geolocation is short for 'Geographic location', and is the name given to the act of finding the actual location of a web page. This can be done either by looking at the IP address1, by looking for company addresses on websites, or by the user adding the information of their whereabouts to the code in their web page. The last option is the easiest and most accurate, and can be used to search the internet for pages in a certain area, making it easy to find nearby bars, restaurants and shops by geographically locating their websites.
How Does It Work?
All web pages are written in the same computer code, known as HTML2. This code is transformed by your web browser into the web pages you see, but is also read by search engines when they search the web for the most appropriate sites. This has lead to the introduction of lines of code that aren't displayed by your browser but are read by search engines, and geolocation makes use of this fact.
The location of a web page is stored at the top of the HTML code, and is based upon the decimal notation of international latitude and longitude - the lines you see on a globe. For example, if a website was run by 'The Red Lion' public house in Brompton at latitude 57.474420 and longitude -0.070317, then the HTML geolocation code could be:
<meta id="DC.title" content="The Red Lion" />
<meta id="geo.position" content="57.474420,-0.070317" />
<meta id="geo.placename" content="Brompton" />
<meta id="geo.country" content="GB" />
A location-based search engine such as a2b reads this part of the code when searching the web, and so the engine can then display a list of the closest places to the location you entered. This is especially handy if you combine portable internet access with a GPS receiver, as you can find out where you are and then use the internet to discover the locations of nearby shops and attractions. In short, the main concept of the system is:
- You own a business, which has it's own website.
- You add the code so that your website is geolocated to where you really are.
- Someone nearby uses a search engine to find the nearest websites to where they are.
- They are informed that you are nearby, and so they wander over to your business and provide you with custom.
How To Add Geolocation Code To Your Website
Firstly, you need to determine your website's location. You can either use a GPS device, or alternatively you could look up the location of your site using Multimap or Streetmap, making sure in either case that you note the international location3. If the website is personal, you may want to give the location of a nearby landmark instead of the location of your home.
Assuming you know HTML already, the next step is to add the following code to your website in the <HEAD> section:
<meta id="DC.title" content="the name of your website" />
<meta id="geo.position" content="latitude,longitude,elevation" />
<meta id="geo.placename" content="the name of your area" />
<meta id="geo.country" content="ISO 3166 country code" />
Although you only really need to give the latitude and longitude of your page, the above code allows you to give your elevation, the name of the place where you are, and the country in which you are situated4. See the example at the start of the entry if you have problems understanding the code.
Other Types of Geolocation Code
Although the above code system may seem more than sufficient, there is another type of code known as the NAC system. The system uses a different code: <meta id="NAC" content="GZTF7 RK39Q">, and in order to find out the code for your website you must contact the company which runs the system, and you may have to pay. Although this may seem like a strange idea, it is supported by Microsoft, and so may end up being made the dominant type of geolocation code.