[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Landing Page by Geographical Location

Posted on 2011-02-17
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
LVL 40

Expert Comment

by:Gurvinder Pal Singh
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

by:Gurvinder Pal Singh
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.

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.


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

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 498 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 501 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 501 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

// MAN PAGE: http://www.iana.org/numbers/

$url = "http://api.geoio.com/q.php?key=$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='http://maps.google.com/maps?f=q&source=s_q&hl=en&q=$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 111

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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

649 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