GeoIf is a free service that dynamically replaces Geobytes’ place-holders within your page’s content with the location details of the user’s location.  You use it by pasting a small code snippet into the bottom of your page, and then placing Geobytes’ place-holders throughout your page’s content – where you would like the site visitor’s geographic information to appear.

Being JavaScript based, it requires only the ability to paste JavaScript code in to your page content, and requires no special software or plugins to be installed on your server.

The code that you paste at the bottom of your page looks like this:

And the place-holders look like this:

Geobytes’ Country Place-holders Sample Data Description
geobytescountryid geobytescountryid The primary key of the countries table.
geobytescountry geobytescountry The country name of a given country.
geobytesfips104 geobytesfips104 ASFIPS 10-4.
geobytesiso2 geobytesiso2 The “A 2” column in the ISO 3166 document.
geobytesiso3 geobytesiso3 The “A 3” column in the ISO 3166 document.
geobytesison geobytesison The “Number” column in the ISO 3166 document.
geobytesinternet geobytesinternet The “ccTLD” code designated by IANA*.
geobytescapital geobytescapital The capital city of a given country.
geobytesmapreference geobytesmapreference The major reference point in the world of the given country.
geobytesnationalitysingular geobytesnationalitysingular The singular expression of a given countries nationality.
geobytesnationalityplural geobytesnationalityplural The plural expression of a given countries nationality.
geobytescurrency geobytescurrency The currency of the given country.
geobytescurrencycode geobytescurrencycode The currency code of a given country.
geobytespopulation geobytespopulation The population of a given country.
geobytescountrytitle geobytescountrytitle The given country’s title as it would appear in a sentence.
Geobytes’ Region Place-holders Sample Data Description
geobytesregionid geobytesregionid A variable holding the primary key of the regions table of a given region.
geobytesregion geobytesregion A variable holding the region name of a given region.
geobytescode geobytescode A 2 character code used to represent the general abbreviation for a sub-country geographical region.
geobytesadm1code geobytesadm1code Used to identify a geopolitical region at a sub-country region level.
Geobytes’ City Place-holders Sample Data Description
geobytescityid geobytescityid A variable holding the primary key of the cities table of a given city.
geobytescity geobytescity A variable holding the city name of a given city.
geobyteslatitude geobyteslatitude A variable holding the latitude of a given city.
geobyteslongitude geobyteslongitude A variable holding the Longitude of a given city.
geobytestimezone geobytestimezone A variable holding the Timezone of a given city.
geobyteslocationcode geobyteslocationcode A variable holding the GeobytesLocationCode of a given city.
Geobytes’ Subnet Place-holders Sample Data Description
geobytescertainty geobytescertainty A variable used to indicate certainty.
geobytesisproxyforwarderfor geobytesisproxyforwarderfor A variable used to indicate that the connection is being made by a Proxy.
geobytesisproxynetwork geobytesisproxynetwork A variable used to indicate that the user is connecting via a ProxyNetwork (AOL or MSN TV).
geobytesipaddress geobytesipaddress A variable that stores an IP Address.

All that you need to do is place this piece of code at the bottom of your page, and then insert the place holder from the above table in your page content where you would like your site visitor’s location information to appear.

Finally, there is one optional parameter that you can use to set the location that the script uses, in the 1% or so of cases where our server is unable to determine your site visitor’s location. The default location – if you don’t set this parameter is New York, however, you can set it to other locations via the “defaultlocation” parameter as shown in this example:

In addition to Geobytes Location Code (which you can lookup here), you can also use an IP Address – as in this example:

or a fully qualified city name – as in this example:

BTW If you would like to see a live real life example, then view the source of this page, as this is how the sample data in the above table is being populated.

How do I see what it would look like from other locations?

If you replace the above single line of code discussed above with the code below, then you can override the location that the script uses by appending the “location parameter” to your page URL.


Here are some examples of using the location over-ride – once again using this pages URL as a demo.

This first one is using a Geobytes Location Code as the over-ride.  You can lookup location codes here.

http://www.geobytes.com/geoif/?location=USNYNYOR

The next example, uses an IP Address to over-ride the location of the page.  It is particularly useful when you need to see the page how it was seen by one of your site visitors, and you know their IP Address.

http://www.geobytes.com/geoif/?location=69.16.219.22

Finally, this last sample is great when you know the formal fully qualified city name, and don’t want the hassle of looking up the location code. (Most browsers will replace the spaces in the location name with %20 but you do need to remember to correctly format the name with spaces and comas in the first place.)

http://www.geobytes.com/geoif/?location=San%20Francisco,%20CA,%20United%20States

How can this be free?

Let’s face it, at 1,024 lookups per hour for each of your site visitors it is very unlikely that any site will ever exceed the “Free usage” threshold – which is really only there to allow us to limit abuse and to identify and mitigate denial of service attacks.

The reason that we can offer this service for free is because servers and bandwidth are very cheap nowadays, and to be honest we make enough out of the ads that you see on this page to fully fund the service.  So in a way, you have already paid for it – just by visiting this page in the first place.

After saying that, if you are really keen and want to pay more, then you may like to consider buying some Mapbytes, and thereby becoming a VIP member.  Being a VIP member does have its privileges.

Disadvantages

The script has to wait until the page has loaded before it can search and replace the geographic place-holders – during which time the site visitor may notice a place holder, and then see it change to their city –  dynamically – right in front of them.  If this is a problem, then you may like to consider one of our other services – such as GeoDirection.

Another possible disadvantage is that the service is implemented client side, so a sophisticated user can easily view the page source and figure out how to fake their location.  This is not the service to use if you need to restrict access to your content based on the users location – for that you will need a server side solution such as our GetCityDetails API – which can be used either server-side or client-side, but in this case you would implement it server side – say from a php script like this:

   function getIP() {
      foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
         if (array_key_exists($key, $_SERVER) === true) {
            foreach (explode(',', $_SERVER[$key]) as $ip) {
               if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
                  return $ip;
               }
            }
         }
      }
   }
   
   $json = file_get_contents('secure.geobytes.com/GetCityDetails?key=7c756203dbb38590a66e01a5a3e1ad96&callback=callback&fqcn='. getIP()); 
   $data = json_decode($json);
   echo ''. getIP() .' resolves to:
'. var_dump($data);

BTW There is a code sample of this approach at the bottom of our IP Locator page.

– because everybody's somewhere