Click here to Skip to main content
Licence 
First Posted 28 Nov 2002
Views 206,380
Downloads 1,992
Bookmarked 73 times

GeoIP - Where are your internet visitors coming from?

By Per S | 31 Aug 2003
Where are your internet visitors coming from?

1

2

3
3 votes, 18.8%
4
13 votes, 81.3%
5
4.81/5 - 19 votes
μ 4.58, σa 0.71 [?]

Introduction

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 - http://www.maxmind.com/)


Click on the image for a test

Note

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.

Prerequisite

(Updated 1.sep.03, new urls) You need the GeoIP database - http://www.maxmind.com/app/standard, and you need ADO 2.5 or later since GeoIP.asp uses the ADO Stream object to read the GeoIP database.

Installation

  1. Download the GeoIP.dat database from MaxMind
    http://www.maxmind.com/app/standard
  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
    http://yourserver/path/example.asp

Methods and Properties

GeoIP.asp exposes these public methods and properties

Properties

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

Methods

  • 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:

<!--#include file="GeoIP.asp"-->
<%
Dim oGeoIP,strErrMsg
Dim strIP,strCountryName,strCountryCode

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

Have fun coding, Per

License

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

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionCities? Pinmemberzorlus4:19 22 Nov '09  
QuestionHow to make custom geo-Ip solution... PinmemberAlex Kucherenko7:28 15 Sep '08  
GeneralOne more... PinmemberVasudevan Deepak Kumar23:48 7 Mar '06  
GeneralEuropean Union PinmemberSehl6:04 11 Jan '06  
GeneralTHANK U ! Pinmemberxlsc11:34 10 Apr '05  
GeneralSvensk flagga istället för Dansk Pinmembermicke114:46 22 Aug '04  
GeneralRe: Svensk flagga istället för Dansk PinsussPer Søderlind16:11 22 Aug '04  
GeneralRe: Svensk flagga istället för Dansk Pinmembermicke116:35 22 Aug '04  
GeneralExcellent PinsussAnonymous14:48 10 Aug '04  
GeneralI am not in the USA PinsussAnonymous1:32 12 May '04  
GeneralRe: I am not in the USA PinmemberLandarzar6:14 6 Aug '06  
GeneralError PinsussAnonymous23:50 22 Feb '04  
GeneralRe: Error PinsussPer Søderlind0:25 23 Feb '04  
Generalerror PinmemberZaboss0:08 29 Dec '03  
GeneralRe: error PinsussPer Søderlind0:31 29 Dec '03  
GeneralRe: error PinmemberZaboss0:43 29 Dec '03  
GeneralFind users' city, region and country if ...... Pinmembergaryyuan10:43 9 Sep '03  
GeneralRe: Find users' city, region and country if ...... PinmemberPer Soderlind11:16 9 Sep '03  
GeneralRe: Find users' city, region and country if ...... Pinmembergaryyuan11:27 9 Sep '03  
GeneralRe: Find users' city, region and country if ...... PinmemberPer Soderlind11:36 9 Sep '03  
GeneralRe: Find users' city, region and country if ...... PinsussLomax_zzz17:17 1 Jan '05  
GeneralNice! Like it Pinmemberaspstudio13:37 1 Sep '03  
GeneralAwesome PinmemberLarry Antram17:34 12 Jan '03  
GeneralExcelent PinmemberJulio Rios8:29 10 Dec '02  
GeneralRe: Excelent PinmemberPer Soderlind9:37 10 Dec '02  

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

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

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