Difference between revisions of "MaxMind's GeoIP Integration"

From AbleCommerce Wiki
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 17: Line 17:
 
#. Extract ''GeoLiteCity.dat.gz'' zip file and place ''GeoIP.dat'' file into your store's ''App_Data'' folder.   
 
#. Extract ''GeoLiteCity.dat.gz'' zip file and place ''GeoIP.dat'' file into your store's ''App_Data'' folder.   
 
#. Extract ''csharp2_1_10.tar.gz'' file and move ''cityExample.cs'',countryExample.cs, ''netspeedExample.cs'', ''orgExample.cs'', ''regionExample.cs'' file to some other folder. Those are samples and will help you under stand how to use available API classes to get information.
 
#. Extract ''csharp2_1_10.tar.gz'' file and move ''cityExample.cs'',countryExample.cs, ''netspeedExample.cs'', ''orgExample.cs'', ''regionExample.cs'' file to some other folder. Those are samples and will help you under stand how to use available API classes to get information.
#. Move remaining API classes to your store's ''App_Code'' folder.
+
#. Move remaining API classes to your store's ''App_Code'' folder and specify some suitable namespace upon them.
 
#. Now you can query data against IP address to find location information as below
 
#. Now you can query data against IP address to find location information as below
 
<pre>
 
<pre>
Line 23: Line 23:
 
LookupService lookupService = new LookupService(path, LookupService.GEOIP_STANDARD);
 
LookupService lookupService = new LookupService(path, LookupService.GEOIP_STANDARD);
 
Location location = lookupService.getLocation("ipAddress here");
 
Location location = lookupService.getLocation("ipAddress here");
Response.Write(location.countryName);
+
Response.Write(location.city);
 
</pre>
 
</pre>

Latest revision as of 11:39, 19 May 2009

What is GeoIP?

With GeoIP you can detect where your visitors are coming from. You can use this information to deliver personalized information, reducing credit card fraud, analyzing web server logs.

About MaxMind

Founded in 2002, MaxMind is an industry-leading provider of geolocation and online fraud detection tools.

MaxMind provides its geolocation technology through the GeoIP brand. By accurately pinpointing the location of Internet customers and visitors by country, geographic region, down to the granular detail of city in real-time, MaxMind enables online businesses to have a valuable marketing tool as well as the ability to customize their websites to better serve clients.

How to integrate AbleCommerce powered store with MaxMind?

First of all you need to have data file containing GeoIP information. In order to write this WIKI topic I used a free data file available at MaxMind GeoLite City Binary Format.

  1. . Download the MaxMind GeoLite City Binary Format database from MaxMind
  2. . Download the .NET C# library code available here at MaxMind.
  3. . Extract GeoLiteCity.dat.gz zip file and place GeoIP.dat file into your store's App_Data folder.
  4. . Extract csharp2_1_10.tar.gz file and move cityExample.cs,countryExample.cs, netspeedExample.cs, orgExample.cs, regionExample.cs file to some other folder. Those are samples and will help you under stand how to use available API classes to get information.
  5. . Move remaining API classes to your store's App_Code folder and specify some suitable namespace upon them.
  6. . Now you can query data against IP address to find location information as below
string path = Server.MapPath("~/App_Data/GeoIP.dat");
LookupService lookupService = new LookupService(path, LookupService.GEOIP_STANDARD);
Location location = lookupService.getLocation("ipAddress here");
Response.Write(location.city);