PDA

View Full Version : Geotargeting by GeoIP integration


The M.I.P.
02-02-2006, 10:00 PM
This plugin uses Maxmind's GeoIP database (http://www.maxmind.com/app/geoip_country) to look up a visitor's country depending on his IP-address.
You may use this e.g. to display specific content or advertisements depending on the geographical location of your visitors.

Installation:
Download geoip.inc (http://www.maxmind.com/download/geoip/api/php/geoip.inc) PHP module and save it in your forum's includes/ directory.
Download the latest GeoLite Country Database (http://www.maxmind.com/app/geoip_country) GeoIP.dat.gz, uncompress it (gunzip or evil ones like WinRAR) and save the uncompressed file under includes/GeoIP.dat (you can change the location of this file in your vBulletin Options).
You should update this file once in a while.
Make sure to have plugin system enabled.
Install product mip-geoiptracker-1.0.xml
Usage:
Use $bbuserinfo[country] (or $vbulletin->userinfo[country]) in your code, your templates, etc.
Have a look on the plugin sources and on GeoIP PHP API (http://www.maxmind.com/app/php) if you're interested in getting infos other than the country code.

Changes:
1.0.1 --> 1.0.2
Fixed bug with geoipdatfile setting not being included in product.
1.0 --> 1.0.1
Basic caching is done using cookies.

This plugin is likely to work also with commercial versions of Maxmind GeoIP databases, which would - with minor tweaks - allow resolving a user's location down to region and even city levels.

On high-traffic sites, I recommend using GeoIP PHP extension or Apache module instead of this plain PHP code.

Please note that I don't give free support for this plugin, as the vBulletin part is too simple and the rest is code from Maxmind (http://www.maxmind.com/download/geoip/api/php/geoip.inc).

AshokForums.com
02-03-2006, 09:33 AM
Thanks.. Installed

TTG
02-03-2006, 09:51 AM
Looks interesting .. does it do any better than simply using this (http://www.dnsstuff.com/)

Zia
02-03-2006, 10:58 AM
sounds nice...will it be a reason of heavy server load?

The M.I.P.
02-03-2006, 02:36 PM
sounds nice...will it be a reason of heavy server load?This depends on your server. If your server is already running with high loads, you will definitely experience a loss of performance.
It's a non-intrusive plugin, so just give it a try.

The Maxmind guys basically included an option to use shared memory on Un*x machines (requires PHP with --enable-shmop), so that file i/o can be reduced and the db is kept in memory only once.
While this is a good idea in principle, its implementation is not unproblematic (e.g. because there's only a fixed shm key). So I did not use it in this plugin - but feel free to extend it.

If you need high-performance geotargeting, you'd be better off with using a different approach like GeoIP Apache module (http://www.maxmind.com/app/mod_geoip).

Snake
02-03-2006, 06:40 PM
<font color="#15a018">* Aftermath installs</font>

IrPr
02-03-2006, 07:38 PM
Nice one
but i could be a complete modification that shows Country code or flag is postbit(legacy) and member profile area...

Borimikan
02-03-2006, 11:09 PM
where is the best place to have this on? in what template?

IrPr
02-04-2006, 07:51 AM
where is the best place to have this on? in what template?

Postbit / Memberinfo

The M.I.P.
02-04-2006, 09:00 AM
where is the best place to have this on? in what template?
Postbit / Memberinfo
Don't forget that this plugin doesn't save its data in the users table or in a userfield. Location info is only available for a user/visitor who is currently surfing your forums.

The perfect use is to display banner ads depending on the geographic location of a visitor or to show location-specific content.

GamerJunk.net
02-04-2006, 11:36 AM
Awesome, I can't wait to play around with this.

steven s
02-04-2006, 12:30 PM
Is there an example of this?

Bad Bunny
02-04-2006, 01:12 PM
Is there an example of this?

If there were an example, you would not know it, since it is unlikely you would be able to change your country to view a different set of ads.

steven s
02-04-2006, 06:07 PM
If there were an example, you would not know it, since it is unlikely you would be able to change your country to view a different set of ads.I reread the description and now understands. I guess this is similar to what adsense does since I often have ads that are local.

TomasDR
04-28-2006, 01:11 AM
Anyone know how to include this in online.php?

I have it all set except it is grabbing the country from the first user and listing that country all the way down, it's not working for each individual user.

akanevsky
04-29-2006, 01:33 AM
What is the basic algorithm used in the inc file to retrieve country info based on ip (I don't feel like reading it through)?

EDIT:

Nevermind, it's based on DNS resolver... And DNS queries may cause page load delays, although not necessarily server load.
Bleh. Not interesting.

meera
03-14-2007, 01:15 PM
Ok someone could help me.

I want only display specific country ads. Can some show example how can this be done..

kafi
03-30-2007, 10:13 PM
Great add-on, I was just looking for it.

Does it work on 3.6x? I pray it does :-)

brandondrury
10-21-2007, 03:55 PM
Great! I've been needing a solution like this.

Would there be any performance gains from simply deciding what country the user is from when they register and just keeping that in the userfield database?

Brandon

Tom Freeman
11-27-2007, 10:55 AM
Sorry if this is a dumb question, but does this mod also allow me to geolocate forums. Therefore only showing certain forums to certain users based on their geographic location?

Thanks,
Tom

Thomas P
05-27-2008, 07:36 AM
Is it possible to block certain IPs based on their geolocation using this hack?

imported_silkroad
08-29-2009, 10:16 AM
Nevermind, it's based on DNS resolver... And DNS queries may cause page load delays, although not necessarily server load.
Bleh. Not interesting.

No, this is wrong.

This program is based on IP address which comes "without network load cost" from the HTTP $_SERVER['REMOTE_ADDR'] global PHP var.

Basically, the server simply takes the REMOTE_ADDR (IP address) and queries a file on the same server (can download file for free) and returns country information.

This is a great feature for many forums that would like to display different content to the user based on country.

imported_silkroad
08-29-2009, 10:18 AM
Is it possible to block certain IPs based on their geolocation using this hack?

Yes, you can easily do this, but you need to write the extra code yourself.

imported_silkroad
08-29-2009, 10:19 AM
Sorry if this is a dumb question, but does this mod also allow me to geolocate forums. Therefore only showing certain forums to certain users based on their geographic location?

Thanks,
Tom

Yes, it does. Basically, with a bit of writing code, you can do "just about anything" based on Country (or even City).

For many users, it might be easier just to install this PHP extension (since this mod is not supported anymore):

http://us3.php.net/manual/en/book.geoip.php

imported_silkroad
08-31-2009, 07:48 AM
Ah, we found it was easier to install Apache2 mod_geoip (http://www.maxmind.com/app/mod_geoip). A plugin for this is not really necessary, FYI. So, I recommend mod_geoip for this because it is easy to install and runs great.

imported_silkroad
09-08-2009, 08:00 AM
We have integrated GeoIP into vBulletin very easily using mod_geoip.

Details on upgrading mod_geoip here (http://www.unix.com/web-programming-web-2-0-mashups/118654-apache2-mod_geoip-upgrade.html)

What we have done so far, is use mod_geoip for geo-targetting.

In addition, we made a simple change to the navbar template to say:

Welcome from Country_Name, User_Name

instead of the standard, Welcome, User_Name

Details on vB navbar feature here. (http://www.unix.com/post-here-contact-site-administrators-moderators/118697-geoip-new-welcome-message-navbar.html)

clubvr4
08-17-2010, 10:36 AM
Has anyone ported this to vb4 yet?

Dave234
06-11-2012, 06:38 PM
Does this work with vbulletin 4.1.11? Does it work with Amazon Associates?