|
||||||
| PHP Tutorials PHP Tutorials |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Have you ever wanted to find out where a visitor lives?
I had the need a week ago when an ad company said that they had lots of advertisers that needed UK visitors. So they asked if I could show their ads for all my UK visitors. Now I have a solutions that I thought that I would share with you. First of all download and unpack Maxminds geoip database. It's free (atleast this version) and can find out what country a visitor come from depending on their IP address. They say it's 97% accurate. Download the database and unzip (gunzip -d GeoIP.dat.gz on linux) Download the PHP api and save as geoip.inc This database is pretty big, so we only want to use it as few times as possible. Because of that we will store a visitors countryCode in a cookie. So it's only the first time he/she visits our site we use the databse. The reset of the time the cookie i used. Smart :-) PHP Code:
So if you want to show special ads for all swedes you can use this code: PHP Code:
The database is updated once every month, in the beginning so make sure you update... Good luck!! Source: Front Page | Pixel Groovy - Last edited by John; 01-07-2007 at 12:24 AM. Reason: Please use the [php], [code], and [html] functions when appropriate, makes it easier to read. :) |
| Sponsored Links |
|
|
|
|||
|
Excellent script dude, I really like it.
Especially as my new site is for only Sri lanka and I can inform this to others by this command, but is Srilanka included in the Database ? as it's BIG, it may take time first time. And nowadays people block Cookies lol, I saw on a thread saying so, I clear cookies once a day or less. |
|
|||
|
Thanx a bunch!!
And you don't want to worry about cookie things, if you are going to publish targeting the users only in Sri Lanka. Because most of the users (almost more than 90%) in Sri Lanka don't block the cookies as for the Stats. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to get ip of the visitors | kool | General Programming | 1 | 08-22-2007 09:42 AM |
| how to get ip of the visitors | AntonyLT | ASP, ASP.NET and Coldfusion | 1 | 06-14-2007 06:43 AM |
| 14 Ways to SEO Wordpress | xtraze | Search Engine Optimization | 4 | 04-23-2007 06:03 PM |
| Target Words | mysticalone | Affiliate Marketplace | 0 | 01-25-2007 03:15 AM |
| Getting your Visitor's Details Using PHP | Ronin | PHP Forum | 1 | 05-15-2006 02:56 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 97%