Landing Page by Geographical Location

Posted on 2011-02-17
Last Modified: 2013-11-19
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!!
Question by:tols12
  • 5
  • 3
  • 2
  • +1
LVL 40

Expert Comment

ID: 34923423
use geolocation APIs to fetch the client's longitude and latitude, and accordinly decide the landing page

see this link for help on redirection

Author Comment

ID: 34923478
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.
LVL 40

Expert Comment

ID: 34923508
<<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.

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.


Author Comment

ID: 34923621
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?
LVL 40

Assisted Solution

gurvinder372 earned 166 total points
ID: 34924050
<<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


Author Comment

ID: 34956761
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.

Author Comment

ID: 35360079
I still haven't resolved the issue. I will still need some help.
LVL 33

Accepted Solution

shalomc earned 167 total points
ID: 35361133
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.

LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 167 total points
ID: 35361670
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


Author Closing Comment

ID: 35733460
I never really got it working. It is partially done. The answers were really confusing to follow.
LVL 110

Expert Comment

by:Ray Paseur
ID: 35733603
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?

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS style formatting? 2 28
Drop Down not working in mobile- Bootstrap 14 29
How to calculate height of a text using jquery 3 40
Validating Date 4 28
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question