Sitecore Blog: @sitecorejohn blog

Spoof an IP Address to Test GeoIP Lookups with the Sitecore Customer Engagement Platform

By John West, May 23, 2011 | Rating:  | Comments (4)

This blog post describes how you can spoof an IP address to test GeoIP lookups with the Sitecore Customer Engagement Platform (CEP).

GeoIP information is increasingly important to creating dynamic, personalized web sites, so much so that Sitecore believes (somewhat subjectively) that in the Digital Marketing System (DMS - previously OMS), GeoIP lookup routines are the APIs used most frequently in the content delivery environment. This is definitely the case in the http://sitecore.net implementation.

When working with Sitecore, if you use a single machine as both the browser client and the web server, such as when doing development on your workstation, the server likely sees the IP address of the client as 0.0.0.0 or 127.0.0.1. GeoIP information providers do not return information about reserved IP addresses.

You can implement a solution based on this prototype startTracking pipeline processor that overrides the IP address associated with the client. If tracking is active and if GeoIP information is availble for the request, if the current request is associated with either of the two IP addresses listed previously, this processor uses the handy Sitecore.Web.WebUtil.ExecuteWebPage() method to retrieve a dynamic web page that contains only the public IP address of the server, and overrides the client's IP with that address. You could use this approach to handle other requirements, such as testing specific IP addresses.

Note the use of the Tracker.Visitor.DataContext.GetGeoIp(). This method associates an IP address record with the request rather than associating an IP address with the request. If two visits come from a single IP address, the result is a single record in the database. This reduces storage requirements slightly, but more importantly, simplifies various aspects of reporting.

To use the prototype, add the processor after the existing InitializeTracker processor in the startTracking pipeline defined in the /App_Config/Include/Sitecore.Analytics.config file:

<startTracking>
  <processor type="Sitecore.Analytics.Pipelines.StartTracking.InitializeTracker,Sitecore.Analytics" />
  <processor type="Sitecore.Sharedsource.Analytics.Pipelines.StartTracking.OverrideIPAddress, assembly" />
...

Tags: API, Architecture, Infrastructure, Website Visitor Context, Personalization, GeoIP

Comments

  • Hi John,

    I'm trying to implement this but I can't find in which namespace the class Tracker is situated.
    I'm using v6.3 of sitecore. Is it only supported in later versions?

    Thx!

    - Lieven Praet
    May 25, 2011 at 6:15 AM

  • Sitecore.Analytics.Tracker in 6.5, probably Sitecore.Analytics.AnalyticsTracker in previous versions. Sorry, I only investigated this with the 6.5 CTP. There is probably something similar in 6.3, but I don't know exactly where. It looks like you must set the Sitecore.Analytics.AnalyticsTracker.CurrentSession.Ip property.

    http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%206/Technical%20Preview.aspx

    - John West
    May 25, 2011 at 7:43 AM

  • Hi John,

    This functionality is exactly what I need so I was happy to find your page, but it looks like the whatsmyip automation page has been removed (http://www.whatismyip.com/automation/n09230945.asp) and returns a 404. Know of any replacements for this?

    Thanks.

    - Jason Georgiades
    June 13, 2011 at 4:09 AM

  • Ok I found that they've moved it to http://automation.whatismyip.com/n09230945.asp

    Thanks

    - Jason Georgiades
    June 13, 2011 at 5:14 AM

*
*
*

Learn More with Sitecore

Newsletter
*

WebTrends | Read Case Study >

From the very start Sitecore’s architecture, whether out of the box or through customization, has been able to meet every business need thrown at WebTrends.com.

- Nate Manley, WebTrends, Inc.