Ajax software
Free javascripts
↑
Main Page
{
echo “Welcome, visitor! We couldn’t find your country code!” ;
}
else
{
echo “Welcome, visitor! Your country code is: “ . SimpleGeoTarget::getRegion();
}
?>
8.
Now, if Jaimie from the United States loaded this script, he would get the output shown in
Figure 11-5. If Cristian loaded the same script, he would get the output shown in Figure 11-6.
Figure 11-7
In this exercise you presented different output depending on the country the visitor is from. Another popu-
lar use of geo-targeting involves redirecting visitors to localized web sites depending on their region. This
example is analogous to the example of Google’s practice of redirecting visitors from foreign countries from
www.google.com
to their respective local version of Google.
Note that when loading the script from your local machine, your IP is 127.0.0.1, which
doesn’t belong to any country — so the message you’d get is “Welcome, visitor! We
couldn’t find your country code!” To test your region, you need to supply your net-
work IP address as the second parameter of
SimpleGeoTarget::isRegion()
, or as
the first parameter to
SimpleGeoTarget::getRegion()
.
240
Chapter 11: Cloaking, Geo-Targeting, and IP Delivery
c11.qxd:c11 11:01 240
Ajax software
Free javascripts
→