Chapter 22 - Targeting Content with GeoIP Information

GeoIP support lets you target your messaging to specific audiences based on current geographical location. Ektron CMS400.NET uses a site visitor’s IP address to detect the location.

Ektron CMS400.NET maintains GeoIP information in a cookie while visitors use the site. When they exit, Ektron CMS400.NET deletes the cookie.

For example, your eCommerce Web site is having a special on snow blowers. That information is relevant to people in Northern climates but of no interest to those living in the tropics. As another example, a site visitor uses his cell phone to find the nearest store location. In this case, Ektron CMS400.NET Map Server Control displays a map of nearby stores based on the user's current latitude and longitude.

This section also contains the following topics.

Targeting Content with GeoIP InformationTargeting Content with GeoIP Information

Choosing a GeoIP Databases

Using GeoIP Information in Ektron CMS400.NET

IP Address Location Information

Ektron CMS400.NET obtains the following information from the IP address of your site visitors.

Information Example

IP Address

208.32.120.10

Country code and name

United States

Region

NH (New Hampshire)

US area code

603

US metro code 506

City

506

US zip code

Nashua

Latitude and longitude

42.7551/-71.4853

Organization

Sprint

Domain name

www.example.com

Retrieving IPAddress Information

Ektron CMS400.NET retrieves the IP address information from a site visitor's IP address via three databases. The databases are installed to your site root's App_data folder and listed in your site's web.config file.

Database (as listed in web.config) Returns the following information, based on IP address

<!-- GeoIP City Database -->

<add key="GeoIpCityDatabase" value="~/App_Data/GeoLiteCity.dat"/>

Area code

City

US State

Country code and name

Latitude and Longitude

MetroCode

PostalCode

Telephone area code

<!-- GeoIP Organization Database -->

<add key="GeoIpOrgDatabase" value="~/App_Data/GeoIPOrg.dat"/>

organization name

<!-- GeoIP Domain Database -->

<add key="GeoIpDomainDatabase" value="~/App_Data/GeoIPDomain.dat"/>

domain name

If you want to move the databases to another folder, you must update their web.config value elements to the new location.

Note: The tilde character (~) in the value element represents the site root folder.

Ektron Best Practice

Ektron recommends keeping the GeoIP databases in the App_data folder, since this folder prevents unauthorized copying of the database.

Choosing a GeoIP Databases

Ektron CMS400.NET includes GeoLite data created by MaxMind, available from http://www.maxmind.com/. If you want, you can purchase more accurate GeoIP databases from MaxMind. The two city databases are contrasted in the following table.

  GeoLiteCity® GeoIP City®
Cost

Free

Purchase from www.maxmind.com

Coverage

Worldwide

Worldwide

Accuracy

Over 99.5% to find user's country

79% to find user's city within a 25 mile radius (US only) 
More details

Over 99.8% to find user's country

83% to find user's city within a 25 mile radius (US only)
More details

Updates

With every release of eWebEdit400

Monthly.

For binary format, weekly and automated updates are available via the GeoIP update program included with GeoIP C API.

Using GeoIP Information in Ektron CMS400.NET

The followingEktron CMS400.NETcomponents provide access to GeoIP information.

Targeted Content Widget

Map Server Control

API

Using GeoIP Information in the Targeted Content Widget

Among the Targeted Content widget's criteria is User Regional Info, which has two options: Country and US Regions.

If you choose US Regions, you can select from states in the United States.

User Regional Info data uses GeoIP information. See Also: Creating Conditions with the Targeted Content Widget

Using GeoIP Information in the Map Server Control

You can center a map on a specific location by using the Map server control's latitude and longitude properties. You also can use GeoIP information to obtain a user's latitude and longitude, based on IP address. For example, if a site visitor searches for a chain restaurant, the map can indicate restaurants near the user.

The following code shows how to set up the Map server control to populate latitude and longitude with GeoIP information.

Sample .aspx page, showing the placement of the Map server control.

<cms:Map ID="uxMap" runat="server" />

Codebehind page in C#**

Ektron.Cms.UserLocationData userLocationData = Ektron.Cms.UserContext.GetCurrentUserLocationInfo();
        if(userLocationData != null)
        {
        	uxMap.Latitude = userLocationData.Latitude;
        	uxMap.Longitude = userLocationData.Longitude;
        }

See Also: Map Server Control Accessing GeoIP Information via API

Accessing GeoIP Information via API

The following API code demonstrates the retrieval of a user's GeoIP information. Note that Ektron.Cms.UserContext.GetCurrentUserLocationInfo() returns the Ektron.Cms.UserLocationInfo() object, which provides access to all elements listed in Retrieving IPAddress Information except IP address.

To obtain IP address, use Ektron.Cms.UserContext.IP.

Ektron.Cms.UserLocationData userLocationInfo = Ektron.Cms.UserContext.GetCurrentUserLocationInfo();
   //If GeoIpCity.dat/GeoIpLiteCity.dat file is present in webconfig
     int AreaCode = userLocationInfo.AreaCode;
     string City = userLocationInfo.City;
     string CountryCode = userLocationInfo.CountryCode;
     string CountryName = userLocationInfo.CountryName;
     double Distance = userLocationInfo.Distance(userLocationInfo);
     int DMACode = userLocationInfo.DMACode;
     double Latitude = userLocationInfo.Latitude;
     double Longitude = userLocationInfo.Longitude;
     int MetroCode = userLocationInfo.MetroCode;
     string PostalCode = userLocationInfo.PostalCode; 
     string Region = userLocationInfo.Region;
     string RegionName = userLocationInfo.RegionName;
     // If GeoIpOrg.dat file and GeoIpCity.dat/GeoIpLiteCity.dat file is provided in web config
     string Organization = userLocationInfo.Organization;
     // If GeoIpDomain.dat and GeoIpCity.dat/GeoIpLiteCity.dat file is provided in web config
     string Domain = userLocationInfo.Domain;
Previous TopicNext Topic|