Landing Page by Geographical Location

I am using Dreamweaver 8 to create our website. I have everything ready except one thing. I have three locations with my business. I have created three separate landing pages for each location. How do i setup my website so if someone in the area of one of my locations visits my site, they're directed to that specific landing page? Ex. I have locations in NYC, LA, Miami. When someone in LA visits my site, they're directed to my LA landing page. If they live in NYC, they're directed to my NYC landing page...etc. Also, if my main location were in NYC, i would want all other states to be directed to my NYC landing page. Does that make sense? What do i need to do to my landing pages (what codes) to set this up? Thanks!!
Who is Participating?
shalomcConnect With a Mentor CTOCommented:
consider getting GeoIP.

This module has a paid version and a free version, and it allows the web server to recognize the location of the user and act accordingly.

There is an Apache module (mod_geoip) that with mod_rewrite can do the job for you without any coding on your pages.

You can also write some php, .net or java code to use the API and recognize the visitor location and act on it.

Gurvinder Pal SinghCommented:
use geolocation APIs to fetch the client's longitude and latitude, and accordinly decide the landing page

see this link for help on redirection
tols12Author Commented:
Thanks for the quick feedback! I looked at both those sites. The first one looks like it gives me some good information on the "example" area. But is there a step by step that i can follow to apply this to my landing pages? It looks like the example will tell me how to look for the geo codes, but how do i put the codes i want on my landing page?

The second site doesn't really show me how to redirect based on location to different landing pages. Is there a step by step instruction? Or could you help me really quickly? It doesn't look too hard, i just don't understand the lingo on some of these sites.
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Gurvinder Pal SinghCommented:
<<but how do i put the codes i want on my landing page?>>
you don't need to put those codes in landing page, you will be fetching them at the onload event of your default landing page.
Each of your pages will have long-lat associated with it. At onload event of default landing page you will find out the client's lat-long. If the lat-long of client does not matches with lat-long of default landing page, then you will find out landing page associated with lat-long of client.  (probably through if else statement)
if you are able to find the landing page associated with client's lat-long, then redirect to that one. Else you need to show the default page.

tols12Author Commented:
Ah, ok. Now it makes a little more sense. So, how do i setup the longitude/latitudes for my landing pages? That first link you sent me had some codes, but there was a TON of information. Could you help translate some of that. I don't understand alot of the HTML lingo. Also, you mentioned if somebody visited that didn't match my longitude/latitude, i probably need to make an if else stmt. How do i do that?
Gurvinder Pal SinghConnect With a Mentor Commented:
<<So, how do i setup the longitude/latitudes for my landing pages? >>
That is the setting/hardcoded-logic that you have to need to implement. May be an array like

var latArray = new Array();
latArray [ "landingPage1" ] = "";
latArray [ "landingPage2" ] = "";
latArray [ "landingPage3" ] = "";

var longArray = new Array();
longArray [ "landingPage1" ] = "";
longArray [ "landingPage2" ] = "";
longArray [ "landingPage3" ] = "";

See, i am just giving an idea on this. Actual example will take a long time. So, i suggest that you first go ahead and try, and let me know if you face any issue.

<<i probably need to make an if else stmt. How do i do that?>>
Yes, after fetching the client lat-long values, you can compare them with the array values to check where they would fall

tols12Author Commented:
Ok, i tried setting up my pages with the above suggestions. I am having a hard time understanding the setup and exactly where i put things.
tols12Author Commented:
I still haven't resolved the issue. I will still need some help.
Ray PaseurConnect With a Mentor Commented:
I have used both Maxmind and GeoIO services.  Here is the general design pattern I use.  Note that it requires you to use a server-side scripting language, such as PHP, to make decisions about which page to load.

1. Call the geolocation algorithm and get the results.
2. Based on the response, either use header("Location...") to redirect or use require_once() to load the appropriate location-aware page script.

GeoIo works great, and it is free if you have a relatively small number of calls.  You need to get a key from the company to use their web service.  An example is in the code snippet.  But it is also an external service, and if their web service is down, you will need to detect that fact and your script will need to do something that makes sense anyway.  That sort of error handling software development is outside of the scope of a small discussion here at EE.

This article shows how you can use MaxMind information to get the country (not the city) from free information.  I believe that you can extend the principles illustrated here to get more narrowly focused geo-location data if you use a larger MaxMind data base.  You may have to pay a subscription fee or buy the data base once a year.

Since you are using this information to define some aspect of the client experience, you might want to ask yourself, "What if a visitor to my web site lives in New York, but wants to get information for her daughter who is traveling from Utah to Los Angeles?"  A good design would have a way for the client to express a preference that is different from the geo-location that your scripts detected.

HTH, ~Ray
<?php // RAY_geoio_example.php


$url = "$key&qt=geoip&d=pipe&q=";

$dat = file_get_contents($url . $ipa);
$inf = explode('|', $dat);

echo "<pre>";
echo PHP_EOL . "CITY: $inf[0] ";
echo PHP_EOL . "STATE: $inf[1] ";
echo PHP_EOL . "COUNTRY: $inf[2] ";
echo PHP_EOL . "CARRIER: $inf[3] ";
echo PHP_EOL . "LAT: $inf[4] ";
echo PHP_EOL . "LON: $inf[5] ";
echo PHP_EOL;

$lnk = "<a target='_blank' href='$inf[4],$inf[5]'>MAP: $inf[4],$inf[5]</a>";
echo PHP_EOL . $lnk;

Open in new window

tols12Author Commented:
I never really got it working. It is partially done. The answers were really confusing to follow.
Ray PaseurCommented:
Wow, you left this question without comment for almost a month and then gave a bad grade?  Answers were confusing??  Did you install and run the sample script I posted for you?  How was that confusing?  Why didn't you ask for more help before closing the question with a bad grade?  What did we do wrong that caused you to mark the answer down by a whole letter grade?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.