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

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.

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.


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 109

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

// 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 109

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
"Go Fund Me" type plugin 5 24
add image on html mail 6 27
Copying table data to one another 15 31
IF statment In Powershell 12 16
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

860 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