Developer forum

Forum » CMS - Standard features » Use GeolocationService.Lookup in solution?

Use GeolocationService.Lookup in solution?

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I can see that GeolocationService.Lookup is public and performs an IP lookup against one of your services. I have a few questions about that:

1. Is it OK to use this method to detect a customer's IP address?

2. Is the remote database with IP addresses updated from time to time? In other words, how reliable is the outcome of the service call?

Thanks!

Imar


Replies

 
Nicolai Pedersen
Reply

No, and no.

The GeolocationService in Analytics requires a license and the data is no longer updated. It was used by the lead tool which is being phased out. Also this API is slow bceause it is a service that makes a tcp connection.

Dynamicweb.Trakcing.Web.Locations has a LocationHelper that can lookup country for an IP fast, and does not require an additional license. But it is currently internal...

Question - where do you need it? To look up the country on a visitor or something else?

If you reference Dynamicweb.Tracking.Web you can subscribe to AfterSessionTracking notification. That will give you a AfterSessionTrackingNotificationArgs object with a Dynamicweb.Tracking.SessionData property that holds the country.

BR Nicolai

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Great, thanks for confirming. Yes, we need it for the customer country so we can redirect them to the correct site. Looks like AfterSessionTrackingNotificationArgs could be what we need.

Cheers,

Imar

 

 
Lars Sørensen Dynamicweb Employee
Lars Sørensen
Reply

Just for my curiosity, where does the LocationHelper look up the country from the ip?

Br.

Lars

 
Nicolai Pedersen
Reply

A binary database distributed with Dynamicweb as an embedded ressource in the Dynamicweb.Tracking.Web dll. It is written to /Files/System/Tracking/GeoIP/

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> A binary database distributed with Dynamicweb as an embedded ressource in the Dynamicweb.Tracking.Web dll. It is written to /Files/System/Tracking/GeoIP/

Yeah, nice, I like that implementation. It checks for the presence of the file and skips it when it exists. That means you can overwrite it with your own updated copy, or delete the file and get the latest from the application. Not sure how often that one is updated though.

Imar

 

 

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I implemented AfterSessionTrackingNotificationArgs and it works well in our test environment but it breaks now in production when the domains have and enforce ssl. Here's what the code does in test:

http://www.domain-staging.fr    -> detects my Dutch IP and redirects to http://www.domain-staging.nl

On production, it seems not to detect my IP (not seeing my code log anything at all) and I stay on https://www.domain.fr

When I turn off "Enforce SSL" on the FR site and browse to http://www.domain.fr, I get properly redirected to http://www.domain.nl (or https://www.domain.fr as that domain also enforces SSL).

Is there a conflict between the new Tracking functionality and the SSL redirects? Is there another place (subscriber or so) I can hook into? Maybe handle this in Global.asax somehow?

Imar

 
Nicolai Pedersen
Reply

You have both domain and ssl redirects in your description as I see it...

Anyways - tracking runs when the Standard.Page.Loaded notification is fired. And then the tracking notifications are fired as part of that.

The redirects to ssl and other domains occur before Page.Loaded notification.

So if you go to http://production.com and have enforce ssl, you are redirected to https://production.com and then on the second request the tracking runs and the tracking notification is fired.

But have you remembered to enable tracking in production...?

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> But have you remembered to enable tracking in production...?

Yep; as I said, it works when I turn off Force SSL on the area. I now use an OnAuthorize subscriber that seems to work better....

Imar

 

You must be logged in to post in the forum