Click here to Skip to main content
11,929,924 members (58,808 online)
Click here to Skip to main content
Add your own
alternative version


75 bookmarked

GeoIP - Where are your internet visitors coming from?

, 31 Aug 2003
Rate this:
Please Sign up or sign in to vote.
Where are your internet visitors coming from?
<!-- Add the rest of your HTML here -->


With GeoIP you can detect where your visitors are coming from. You can use this information to deliver personalized information (see image below), reducing credit card fraud, analyzing web server logs (I use it for SNIFF), target banner ads, .... (see Solutions at MaxMind -

Click on the image for a test


If you can install a component on your web server, you should download the GeoIP component from MaxMind . I wrote GeoIP.asp since my provider doesn't allow me to install components.


(Updated 1.sep.03, new urls) You need the GeoIP database -, and you need ADO 2.5 or later since GeoIP.asp uses the ADO Stream object to read the GeoIP database.


  1. Download the GeoIP.dat database from MaxMind
  2. Put GeoIP.asp, example.asp and GeoIP.dat in a catalog on your web server.
  3. Test the installation by accessing the example.asp page

Methods and Properties

GeoIP.asp exposes these public methods and properties


  • GeoIPDataBase - Sets the path and filename to GeoIP.dat
  • ErrNum - Returns the error number (if <> 0, there's an error)


  • lookupCountryName - Find an IP's country name
    • example: strCountryName = oGeoIP.lookupCountryName(strIP)
  • lookupCountryCode - Find an IP's country code
    • example: strCountryCode = oGeoIP.lookupCountryCode(strIP)

Using the code

It's rather simple to use this code:

<!--<span class="code-comment">#include file="GeoIP.asp"--></span>
Dim oGeoIP,strErrMsg
Dim strIP,strCountryName,strCountryCode

Set oGeoIP = New CountryLookup
oGeoIP.GeoIPDataBase = Server.MapPath("GeoIP.dat")
If oGeoIP.ErrNum(strErrMsg) <> 0 Then
	strIP = request.ServerVariables("REMOTE_ADDR")
	strCountryName = oGeoIP.lookupCountryName(strIP)
	strCountryCode = oGeoIP.lookupCountryCode(strIP)
End If
Set oGeoIP = Nothing

Have fun coding, Per


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Per S
Web Developer
Norway Norway
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionCities? Pin
zorlus22-Nov-09 4:19
memberzorlus22-Nov-09 4:19 
QuestionHow to make custom geo-Ip solution... Pin
Alex Kucherenko15-Sep-08 7:28
memberAlex Kucherenko15-Sep-08 7:28 
GeneralOne more... Pin
Vasudevan Deepak Kumar7-Mar-06 23:48
memberVasudevan Deepak Kumar7-Mar-06 23:48 
GeneralEuropean Union Pin
Sehl11-Jan-06 6:04
memberSehl11-Jan-06 6:04 
GeneralTHANK U ! Pin
xlsc10-Apr-05 11:34
memberxlsc10-Apr-05 11:34 
GeneralSvensk flagga ist&#228;llet f&#246;r Dansk Pin
micke122-Aug-04 14:46
membermicke122-Aug-04 14:46 
GeneralRe: Svensk flagga ist&#228;llet f&#246;r Dansk Pin
Per Søderlind22-Aug-04 16:11
sussPer Søderlind22-Aug-04 16:11 
GeneralRe: Svensk flagga ist&#228;llet f&#246;r Dansk Pin
micke122-Aug-04 16:35
membermicke122-Aug-04 16:35 
GeneralExcellent Pin
Anonymous10-Aug-04 14:48
sussAnonymous10-Aug-04 14:48 
GeneralI am not in the USA Pin
Anonymous12-May-04 1:32
sussAnonymous12-May-04 1:32 
GeneralRe: I am not in the USA Pin
Landarzar6-Aug-06 6:14
memberLandarzar6-Aug-06 6:14 
GeneralError Pin
Anonymous22-Feb-04 23:50
sussAnonymous22-Feb-04 23:50 
GeneralRe: Error Pin
Per Søderlind23-Feb-04 0:25
sussPer Søderlind23-Feb-04 0:25 
Generalerror Pin
Zaboss29-Dec-03 0:08
memberZaboss29-Dec-03 0:08 
GeneralRe: error Pin
Per Søderlind29-Dec-03 0:31
sussPer Søderlind29-Dec-03 0:31 
GeneralRe: error Pin
Zaboss29-Dec-03 0:43
memberZaboss29-Dec-03 0:43 
GeneralFind users' city, region and country if ...... Pin
garyyuan9-Sep-03 10:43
membergaryyuan9-Sep-03 10:43 
GeneralRe: Find users' city, region and country if ...... Pin
Per Soderlind9-Sep-03 11:16
memberPer Soderlind9-Sep-03 11:16 
GeneralRe: Find users' city, region and country if ...... Pin
garyyuan9-Sep-03 11:27
membergaryyuan9-Sep-03 11:27 
GeneralRe: Find users' city, region and country if ...... Pin
Per Soderlind9-Sep-03 11:36
memberPer Soderlind9-Sep-03 11:36 
GeneralRe: Find users' city, region and country if ...... Pin
Lomax_zzz1-Jan-05 17:17
sussLomax_zzz1-Jan-05 17:17 
GeneralNice! Like it Pin
aspstudio1-Sep-03 13:37
memberaspstudio1-Sep-03 13:37 
GeneralAwesome Pin
Larry Antram12-Jan-03 17:34
memberLarry Antram12-Jan-03 17:34 
GeneralExcelent Pin
Julio Rios10-Dec-02 8:29
memberJulio Rios10-Dec-02 8:29 
GeneralRe: Excelent Pin
Per Soderlind10-Dec-02 9:37
memberPer Soderlind10-Dec-02 9:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 1 Sep 2003
Article Copyright 2002 by Per S
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid