Ektron CMS400.Net Reference

>>GEOIP Support > Using GeoIP Information in Ektron CMS400.NET

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 Using GeoIP Information in Ektron CMS400.NET 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;

Visit the Ektron Dev Center at http://dev.ektron.com 1-866 - 4 - EKTRON

Ektron CMS400.NET Reference Version 8.02 SP1 Rev 1

Ektron Documentation,© 2011 Ektron, Inc.