Summary:
Maxmind.com has GeoIP databases that translate an IP address into location information. They have free ones that provide country only information, or paid subscriptions to GeoIP databases that include City, State, Nielsen DMA codes, latitude/longitude, and telephone area codes.
Installation:
This macro uses the lastIP in the session hash to use the Geo::IP libs to return information. In the 7.x version we grab the session->env->getIP() method.
Calling the macro without any parameters will use the default basic country db and will return only the country code.
Calling the macro with a parameter will use the GeoIPCity db - so you need to have that installed (see step 3 above). Acceptable parameters are:
country_code - returns ISO 3166 country code
country_code3 - returns ISO 3166 3 letter country code
country_name - returns the country name
region - returns the region - State/Prov for USA/Canada
city - returns the city name
postal_code - returns the ZIP/Postal Code
latitude - returns the latitude
longitude - returns the longitude
dma_code - returns the Nielsen DMA code for USA
area_code - returns the phone number area code for USA
Possible Uses:
Now combine all this with the dynamic personalization / metadata
features in WebGUI, and you can start automatically populating pages
with content based on a visitors GeoIP data. For example, if you
have multiple event wobjects for different States, show the event
wobject that is tagged with the metadata state tag for the vistors
GeoIPstate, showing a default if no match.
Disclaimers:
This is untested code for 6.8 and 7.x since I didn't have access to the right devel environments... but they should be fine. Let me know if you have any issues.