|
|
Home » ASP » Article
Find Visitor Geographical location from IP address using ASP
|
| Article by: | Per Soderlind (2/26/2003) |
|
| Summary: | Where are your internet visitors coming from? Using simple ASP and the free GEOIP Database from Maxmind its quite easy to find out |
|
| Viewed: 132647 times |
Rating (41 votes): |
|
3.3 out of 5 |
|
|
|
Find Visitor Geographical location from IP address using ASP
Download GeoIP files - 6 Kb
Online Demo
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
You need the GeoIP database - http://www.maxmind.com/app/free, and you need ADO 2.5 or later since GeoIP.asp uses the ADO Stream object to read the GeoIP database.
Installation
Download the GeoIP.dat database from MaxMind
http://www.maxmind.com/app/free
Put GeoIP.asp, example.asp and GeoIP.dat in a catalog on your web server.
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:
|
|
View highlighted Comments
User Comments on 'Find Visitor Geographical location from IP address using ASP'
|
| RELATED ARTICLES |
ASP FilesystemObject by Jeff Anderson
An introduction to the Filesystemobject |
 |
ASP GetTempName by Jeff Anderson
Use the GetTempName method to create a randomly generated temporary file on the server. |
 |
ASP Format Date and Time Script by Jeff Anderson
An ASP script showing the variety of date and time formats possible using the FormatDateTime Function. |
 |
ASP OpenTextFile by Jeff Anderson
An introduction to the OpenTextFile Method of the FileSystemObject |
 |
Email validation using Regular Expression by Jeff Anderson
Using regular expression syntax is an exellent way to thoroughly validate an email. It's possible in ASP. |
 |
Add or Subtract Hours in SQL or ASP using DateAdd by Jeff Anderson
A beginners guide to using the SQL DATEADD function to add or subtract hours. Particularly useful when setting the time displayed on the ASP page to a different time zone (eg when the server is in the US, and the site is for a UK audience). |
 |
The asp:radiobutton and asp:radiobuttonlist control by David Sussman, et al
In HTML, radio buttons are used when we need to make multiple sets of choices available, but we want the user to select only one of them. |
 |
ASP FileExists by Jeff Anderson
An introduction to the FileExistsMethod of the FileSystemObject |
 |
The asp:checkbox and asp:checkboxlist control by David Sussman, et al
Checkboxes are similar to radio buttons, and in HTML, they were used to allow multiple choices from a group of buttons. |
 |
Concatenate strings in sql by Jeff Anderson
A brief introduction to concatenating strings in an sql query (using SQL server or access databases). |
 |
|
| Recent Forum Threads |
|
| Recent Articles |
|
|
|
| © Copyright codetoad.com 2001-2013 |
| |