Username Password
Bookmark and Share

GeoIP macro updates for 6.8 and 7.x

Summary: 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.


  1. Make sure you install the geoip C libs:
  2. Install the Geo::IP module from CPAN
  3. Optionally install/purchase the GeoIPCity db from MaxMind (Note: this is not an endorsement of MaxMind -- just found something that works for us).  If you do, update your webgui.conf file with the path to this db file:

  4. Optionally add a "use Geo::IP" statement to your preload.perl script.

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.


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.

System RequirementsPlease be advised: this contribution was tested with something older than WebGUI 7.5. When this contribution was uploaded there was no field for the author to fill out regarding it's requirements.
LinksNo Support Offered
Statistics Downloads: 1521
Views: 4157
Rating: 0
Updated: 9/17/2006
Keywords macros
NavigationBack to the Bazaar
© 2023 Plain Black Corporation | All Rights Reserved