GeoDirection
GeoDirection is a free service that dynamically redirects internet surfers based
on their geographic location. This JavaScript redirection tool is ideal for
internet users that wish to redirect browsers based on their City, Region or
Country, using Geobytes' IP Address map technology. Further, it can also be used
via the provided Geobytes' JavaScript Variables to insert localized geographic
content into a web page or JavaScript. Note:
There is no need to install any special software on your web server.
Sample Script:
<script language="Javascript"
src="http://gd.geobytes.com/gd?pages=USNYNYOR&ext=html&after=5">
</script>
Sample Content Localisation Script:
<script language="Javascript"
src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity">
</script>
<script language="Javascript">
document.write("<p>Welcome to visitors from "+sGeobytesCity+",
"+sGeobytesCountry);
</script>
Please note, by using Geobytes' GeoDirection service you are agreeing to be
subject to the Geobytes GeoDirection Service
Agreement.
Parameters:
pages: Specifies the page that a person will be re-directed to based on their location.
For example: USNYNYOR would re-direct visitors from the city of New York to a page called
USNYNYOR.html, USCA would re-direct visitors from California to a page called
USCA.html,
while US would re-direct visitors from the United States to a page called
US.html. Note: The order of precedence is city, region, country, meaning a city
match overrides region, and a region match overrides country.
(Alternatively, you can also direct to any specific url - click
here to see the sample below.)
ext: Specifies the file extension of the page you wish to re-direct to. The
default is html.
after: Specifies how long to wait before re-directing the user. Default is
0 seconds (do not wait). -1 = Do not re-direct (allows you to perform your own re-direct to any page
see example)
variables: Specifies the variable(s) to be initialized for use in later
scripts on the page. For a complete reference of the available Geobytes' JavaScript variables
see Geobytes' JavaScript variables.
Quick example: variables=GeobytesCountry,GeobytesCity would initialize the
sGeobytesCountry and the sGeobytesCity JavaScript variables for later use.
Examples:
Code example using the Geobytes' JavaScript variables to redirect visitors from a given Country, Region or City:
<script language="Javascript"
src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesLocationCode,GeobytesCode,GeobytesInternet"></script>
<script language="Javascript">
if(typeof(sGeobytesLocationCode)=="undefined"
||typeof(sGeobytesCode)=="undefined"
||typeof(sGeobytesInternet)=="undefined")
{
// Something has gone wrong with the
variables, so set them to some default value,
// maybe set a error flag to check for later on.
var sGeobytesLocationCode="unknown";
var sGeobytesCode="unknown";
var sGeobytesInternet="unknown";
}
if(sGeobytesLocationCode=="USCALANG")
{
// Visitors from Los Angeles would go here
window.open("enter Los Angeles URL here");
}else if(sGeobytesCode=="CA")
{
// Visitors from California would go here
window.open("enter Californian URL here");
}else if(sGeobytesInternet=="US")
{
// Visitors from the United States
would go here
window.open("enter United States URL here");
}
</script>
The re-direction script as shown in the examples below must be pasted into the
<head></head> section of the page that you are
re-directing your users from.
The following example would re-direct visitors from New York to USNYNYOR.html,
and users from San Francisco to USCASFRA.html. Any other visitors from the US would be
re-directed to US.html. Visitors from other countries will not be re-directed.
<head>
<script language="Javascript"
src="http://gd.geobytes.com/gd?pages=USNYNYOR,USCASFRA,US">
</script>
</head>
The following example re-directs to an .ASP page and waits for 5 seconds.
<head>
<script language="Javascript"
src="http://gd.geobytes.com/gd?pages=USNYNYOR,USCASFRA,US&ext=ASP&after=5">
</script>
</head>
Can you re-direct users to any
page name you like?
Yes, you can use the "sGeobytesLocationCode" Javascript variable to
detect where the user is from, and then issue your own re-direct to any other
page you like. Re-directing your users this way enables you to re-direct users
to any page. For example:
<head>
<script language="Javascript" src="http://gd.geobytes.com/Gd?pages=US&ext=html&after=-1"></script>
<script language="javascript">
if(typeof(sGeobytesLocationCode)!="undefined"&&sGeobytesLocationCode.indexOf('US')==0)
{
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=enter your url here'>");
}
</script>
</head>
The script above would re-direct users from the United States to any page
that you specify, you can also specify a fully qualified url. Just replace
"enter your url here" with the url of the page you are re-directing
your users to.
See the FAQ below for further examples.
How to find out location codes for Cities, Regions, Countries?
The last point you need to know to get geo re-directs running is the location
codes for the cities, regions and countries that you wish to target.
The easiest way is to use our location
code generator, but as you have probably realised now, you can
pretty much guess the code of many of the countries and regions. For example:
The region code is the first 4 characters of the location code, and the country
code is the first 2 characters.
For further assistance with obtaining codes, please see our EpiCenter
or our forums site.
Using the sGeobytesLocationCode Javascript Variable After the GeoDirection
service processes your request it initialises a JavaScript string
variable that is accessible by any JavaScript on the page. The variables name is
"sGeobytesLocationCode" and it's value is set to the location code of the user.
For example: The location code for New York is USNYNYOR. If the user's
location can't be determined it's value is "unknown". You may wish to
use this variable to tell the user something like: "We are now re-directing
you to our New York page... Please Wait..." Following is some sample code:
<script language="javascript">
if(typeof(sGeobytesLocationCode)!="undefined"&&sGeobytesLocationCode=="USNYNYOR")
{
document.write("We are now re-directing you to our New York page...");
}
</script>
GeoDirection FAQ
How do I open the re-directed page in a new window?
Simply use JavaScript's window.open method. For
example, the code below would open a new page redirecting users from California.
<script
language="Javascript" src="http://gd.geobytes.com/Gd?after=-1"></script>
<script language="javascript">
if(typeof(sGeobytesLocationCode)!="undefined"&&sGeobytesLocationCode.indexOf('USCA')==0)
{
window.open("enter url
here");
}
</script>
How many
Geobytes' JavaScript variables are
there and what are their names?
There are 30 Geobytes' JavaScript variables in
total to use, their names with a short summary describing each variable are in
the table below:
| # |
Geobytes' Country Variables
|
Sample
Data |
Description
|
| 1 |
sGeobytesCountryId
|
254 |
The primary key of the countries table. |
| 2 |
sGeobytesCountry
|
United
States |
The country name of a given country |
| 3 |
sGeobytesFips104
|
US |
FIPS 10-4 |
| 4 |
sGeobytesIso2
|
US |
The “A 2” column in the ISO 3166 document |
| 5 |
sGeobytesIso3
|
USA |
The “A 3” column in the ISO 3166 document |
| 6 |
sGeobytesIson
|
840 |
The “Number” column in the ISO 3166 document |
| 7 |
sGeobytesInternet
|
US |
The “ccTLD” code designated by IANA* |
| 8 |
sGeobytesCapital
|
Washington,
DC |
The capital city of a given country |
| 9 |
sGeobytesMapReference
|
North America |
The major reference point in the world of the
given country |
| 10 |
sGeobytesNationalitySingular
|
American |
The singular expression of a given countries
nationality |
| 11 |
sGeobytesNationalityPlural
|
Americans |
The plural expression of a given countries
nationality |
| 12 |
sGeobytesCurrency
|
US Dollar |
The currency of the given country |
| 13 |
sGeobytesCurrencyCode
|
USD |
The currency code of a given country |
| 14 |
sGeobytesPopulation
|
278058881 |
The population of a given country |
| 15 |
sGeobytesCountryTitle
|
The United States |
The given country's title as it would appear in a
sentence. |
| |
|
|
|
| |
Geobytes' Region Variables
|
Sample
Data |
Description
|
| 16 |
sGeobytesRegionId
|
126 |
A variable holding the primary key of the regions
table of a given region.
|
| 17 |
sGeobytesRegion
|
California |
A variable holding the region name of a given
region
|
| 18 |
sGeobytesCode
|
CA |
A 2 character code used to represent the general
abbreviation for a sub-country geographical region
|
| 19 |
sGeobytesAdm1Code
|
|
Used
to identify a geopolitical region at a sub-country region level
|
|
|
|
|
| |
Geobytes' City/Location Variables
|
Sample
Data |
Description
|
| 20 |
sGeobytesCityId
|
7433 |
A
variable holding the primary key of the cities table of a given
city.
|
| 21 |
sGeobytesCity
|
Santa Barbara |
A
variable holding the city name of a given city
|
| 22 |
sGeobytesLatitude
|
34.4119 |
A variable holding the latitude of a given city
|
| 23 |
sGeobytesLongitude
|
119.728 |
A variable holding the Longitude of a given city
|
| 24 |
sGeobytesTimezone
|
8:00 |
A variable holding the Timezone of a given city
|
| 25 |
sGeobytesLocationCode
|
USCASBAR |
A variable holding the GeobytesLocationCode of a
given city
|
| |
|
|
|
| |
Geobytes' DMA Variables
|
Sample
Data |
Description
|
| 26 |
sGeobytesDma
|
855 |
Non-overlapping Designated Market Area (US Only),
used to identify TV stations whose broadcast signals reach a specific area.
|
| |
|
|
|
| |
Geobytes' Subnet Variables
|
Sample
Data |
Description
|
| 27 |
sGeobytesCertainty
|
96 |
A variable used to indicate certainty
|
| 28 |
sGeobytesIsProxyForwarderFor
|
true |
A variable used to indicate that the connection
is being made by a Proxy
|
| 29 |
sGeobytesIsProxyNetwork
|
false |
A
variable used to indicate that the user is connecting via a
ProxyNetwork (AOL or MSN TV)
|
| 30 |
sGeobytesIpAddress
|
207.71.204.77 |
A variable that stores an IP Address
|
|
*IANA - Internet Assigned
Numbers Authority
For a comprehensive description of each of the above fields
see the Understanding the Geo Tags & Geobytes Headers
page.
How could I redirect users from multiple countries to
multiple pages respectively?
The code below would redirect users from the countries within
each variable (ie. var sCountryLocations="US") to be redirected to any
page of a webmasters choice.
<head>
<script language="Javascript" src="http://gd.geobytes.com/Gd?after=-1"></script>
<script language="javascript">
var sSpanishLocations="ES,MX,GT,SV,HN,NI,CR,EC,PE,CU,DO,PR,PA,VE,CO,BO,AR,CL,PY,UY";
var sGermanLocations="DE,AT,CH";
var sFrenchLocations="FR,BE";
var sPhilippineLocations="PH";
var sKoreanLocations="KP,KR";
var sChineseLocations="CN";
if(typeof(sGeobytesLocationCode)!="undefined")
{
var sCountryCode=sGeobytesLocationCode.substring(0,2);
if(sCountryCode!="US"&&sCountryCode!="CA")
{
if(sSpanishLocations.indexOf(sCountryCode)>=0)
{
// Spanish Visitors would go here
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=Spanish.htm'>");
}else if(sGermanLocations.indexOf(sCountryCode)>=0)
{
// German Visitors would go here
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=German.htm'>");
}else if(sFrenchLocations.indexOf(sCountryCode)>=0)
{
// French Visitors would go here
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=French.htm'>");
}else if(sPhilippineLocations.indexOf(sCountryCode)>=0)
{
// Philippine Visitors would go here
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=Philippine.htm'>");
}else if(sKoreanLocations.indexOf(sCountryCode)>=0)
{
// Korean Visitors would go here
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=Korean.htm'>");
}else if(sChineseLocations.indexOf(sCountryCode)>=0)
{
// Chinese Visitors would go here
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=Chinese.htm'>");
}else
{
// World Visitors would go here
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=World.htm'>");
}
}
}
</script>
</head>
How would I redirect users to two different pages?
The code below redirects users from the countries
within Europe to one page and visitors from the United States to another
page. The rest of the world stays on the current page that this
code is pasted onto.
<head>
<script language="Javascript"
src="http://gd.geobytes.com/Gd?after=-1"></script>
<script language="javascript">
var sLocations="US,AL,AD,AT,BE,BG,HR,CZ,DK,EE,FO,FI,FR,DE,GI,GR,"+
"GG,VA,HU,IE,IT,JE,LV,LI,LT,LU,MK,MT,IM,MC,NL,NO,PL,PT,RO,SM,SK,SI,ES,SE,CH,UK,YU";
if(typeof(sGeobytesLocationCode)!="undefined")
{
var sCountryCode=sGeobytesLocationCode.substring(0,2);
if(sLocations.indexOf(sCountryCode)==0)
{
// Visitors from the US
would go here
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=enter url
here'>");
}else if(sLocations.indexOf(sCountryCode)>0)
{
// Visitors from Europe
would go here
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=enter url
here'>");
}
}
</script>
</head>
How would I redirect visitors from the United
States to "http://www.SomeDomain.com" and the rest of the
world to "http://www.restoftheworld.com"?
The code below shows how to, by default let all the
traffic go to "http://www.restoftheworld.com" then re-direct
people from the United States to
"http://www.SomeDomain.com".
<head>
<script language="Javascript" src="http://gd.geobytes.com/Gd?after=-1"></script>
<script language="javascript">
if(typeof(sGeobytesLocationCode)!="undefined"&&sGeobytesLocationCode.indexOf('US')==0)
{
document.write("<META HTTP-EQUIV='Refresh' CONTENT='0;
URL=http://www.SomeDomain.com'>");
}
</script>
</head>
How can this service be FREE?
We are happy to provide this service for free to the web community, all we
ask in exchange is a small amount of advertising.
For approximately every 1 in a 50 redirects the current browser window will be
directed to the Geobytes site or that of a sponsor, the redirect will also open a new window for the
original, intended content. This will not happen to the same person twice in the
same day.
If you wish to remove this ad, then that can be easily done by purchasing
some Mapbytes resolutions. These Mapbytes will allow you to enter the url of the
site on which you use GeoDirection. Any requests from this url will be allowed
access and will not have any ads served. Mapbytes start from $9.95 for 10,000
resolutions. See the Buy
page to purchase Mapbytes or see the FAQ page for
more details.
|