Pre populating forms based on Geotargeting?

Fatbat

Advertise Here
May 10, 2008
6,988
149
63
Costa del Sol, Spain
www.linkedin.com
I want to pre populate order forms based on a visitors geo location... so like, the City, State, Country and Zip/Postal code would automatically be filled in on a form.

Obviously this needs to be accurate, and preferably global. Is this possible? Any downsides you can see?

How would I go about doing this? With Google's geo whowhatsit? Or MaxMind's? What sort of scripting would I use? I'm somewhat retarded in the coding department so I would really use a hand with this.

Thanks in advance!
 


I don't know a lot about geo location type stuff but one thing I do know is that I'm in Texas and every website that uses it thinks I'm in Indiana or something and some City I've never heard of.

I'm sure it has to have something to do with my ISP but I figured I would mention it.
 
I spend the whole day trying to do the same thing.

I use IP Location Script, it cost only $47 and is pretty easy to setup. It's basic php.

What took me the longest was getting the location to show up as default on a form.
I couldn't figure out how to make it work with php, but eventually came up with a work around.
 
Obviously this needs to be accurate, and preferably global. Is this possible?

You should be able to use:

<script src="http://www.google.com/jsapi" language="javascript"></script>
<script language="javascript">
if (google.loader.ClientLocation != null) {
document.write("Yo, how's it going in" + google.loader.ClientLocation.address.city + ", " + google.loader.ClientLocation.address.region);
} else {
document.write("Your Location Was Not Detected By Google Loader");
}
</script>

and play with it adding in {"city":,"region":,"country":"country_code":}}; should you care to, I would think.


As for getting it to work with a form...someone else will have to take that.
 
You should be able to use:

<script src="http://www.google.com/jsapi" language="javascript"></script>
<script language="javascript">
if (google.loader.ClientLocation != null) {
document.write("Yo, how's it going in" + google.loader.ClientLocation.address.city + ", " + google.loader.ClientLocation.address.region);
} else {
document.write("Your Location Was Not Detected By Google Loader");
}
</script>

and play with it adding in {"city":,"region":,"country":"country_code":}}; should you care to, I would think.


As for getting it to work with a form...someone else will have to take that.


Agree!

Had this assembled by a programmer from RAC, dutyfreecredits.com take a look at the source code
it fills up the third invisible Aweber form with the person's city name.
 
Last edited by a moderator:
technically try - "value=<location code>" on input fields, and for option values with a dropdown box "selected="

I personally use php if/else statements with maxmind's geolite downloaded database and php syntax so that a) it's not as easily jackable versus the in-code .js and b) I find there's much faster load times.

I would think about how you do this though- populating state makes sense, however city/zip even though one could change and it seems to shorten the form I find outside of big cities over wide areas these are often off. I'm always told I"m a city or two over, and have anywehre I"ve lived. Even if the city is off the zip is not - since many cities span mulitple zip codes.

Your attempt at shortening the form time committment could turn into confusion or people thinking there's some magic tech problem for idiot users

as for intl data - haven't used them but look at Quova
 
You're setting yourself up for trouble on this in spots. AOL proxies people in many cases, and so do several other ISPs in a way. When I was living in SC, it said my location was Rocky Mount, NC when I was geolocated via IP address
 
the dbs from iplocation and maxmind are also not very accurate unless you buy the pro versions (surprise) - they quoted about 70% accuracy for city/state which was enough for me jack the idea of city tracking in my software when my tests run the same.
you might want to be aware of that as well.
 
OK, I'm just going to stick to country for now.

What's the best way to display something like "We ship to <insert visitor's country here> daily" or "Free shipping to <insert visitor's country here>"?

And

What would be the best way to pre populate the country field on the order form?

So far I've had a couple people suggest Google and javascript, and couple of others suggested PHP and MaxMind GeoIP.

If someone would be so kind as to set this up for me I would be happy to pay them.
 
You're setting yourself up for trouble on this in spots. AOL proxies people in many cases, and so do several other ISPs in a way. When I was living in SC, it said my location was Rocky Mount, NC when I was geolocated via IP address


True, but with forms it'd be very easy for them to change it to the proper state. At least you'd be hitting most your visitors with the correct state.
 
What I did for states is something like this:

<select name="state" type="text" id="state" style="width:150px">
<option value="<?php echo $region; ?>" selected="selected"><?php echo $region; ?></option>
<option>===========</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
...and so on

The problem with this is that the state shows up twice in the drop down menu, once on top(where it is dynamically inserted), and once in alphabetical order in the list.

I can't figure out how to make it automatically select a 'State' in the list dynamically with a geo script. If ya figure this out, hit me up please.
 
What's the best way to display something like "We ship to <insert visitor's country here> daily" or "Free shipping to <insert visitor's country here>"?

And

<script src="http://www.google.com/jsapi" language="javascript"></script>
<script language="javascript">
if (google.loader.ClientLocation != null) {
document.write("Free shipping to" + google.loader.ClientLocation.address.country);
} else {
document.write("Your Location Was Not Detected By Google Loader");
}
</script>



client locations can be:

google.loader.ClientLocation.latitude
google.loader.ClientLocation.longitude
google.loader.ClientLocation.address.city
google.loader.ClientLocation.address.country
google.loader.ClientLocation.address.country_code
google.loader.ClientLocation.address.region
 
Actually, if you leave:

Code:
<select name="state" type="text" id="state">
<option value="<?php echo $region; ?>" selected="selected"><?php echo $region; ?></option>
with a blank label like:

Code:
<select name="state" type="text" id="state">
<option value="<?php echo $region; ?>" selected="selected"></option>
it will still work and will select the value that matches in your list/menu.


Also, I know your thinking of just sticking with country right now, but
a way that you could auto fill for cities/states is passing that information
through your url's query string. Of course, you'd have to be using traffic sources where you could target those demographics individually with unique urls.

I hope this makes sense. I'm kinda out of it right now, but I'm working on the same thing.
 
the dbs from iplocation and maxmind are also not very accurate unless you buy the pro versions (surprise) - they quoted about 70% accuracy for city/state which was enough for me jack the idea of city tracking in my software when my tests run the same.
you might want to be aware of that as well.

itchy,

I didn't buy the paid version because there didn't seem to be much of a difference between GeoLite City [free] and GeoIP City [paid] (79% Vs 83% for US cities) according to their published data. (Never called them, just went by this: MaxMind - GeoLite City | Free Geolocation Database )