Bringing Geo-Location to Web Experience Management

Written by Lars Trieloff

An undisputed goal of Web Experience Management is the ability to provide meaningful experiences to web site visitors. The definition of “meaningful” is closely related to the context the vistor is operating in. With CQ5’s ClickstreamCloud, marketers and developers have an effective tool to aggregate, visualize and analyze their visitor’s context.
In order to understand their customer’s context, marketers have to be as close to their customers minds as possible. The ability to achieve this kind of closeness is greatly increased by the ability to accurately locate the surfer and relate geo-location to geo-spatial resources and content on a web site.

In this blog post, I will show how developers can capture geo-location information from the visitor’s browser, make it available in the ClickstreamCloud and allow marketers to act upon it.

The implementation follows three easy steps:
1. creation of a ClickstreamCloud plugin
2. capturing geo-location data from the browser through the geo-location API
3. storing this information appropriately in the ClickstreamCloud.

1. Creating a ClickstreamCloud plugin
CQ5’s ClickstreamCloud is extensible through plugins that can be loaded by dropping simple JSP files under /apps/cq/personalization/components/clickstreamcloud/plugins

If this is your first custom ClickstreamCloud plugin, open CRXDE lite and create a folder at /apps/cq/personalization/components/clickstreamcloud/plugins

Then create a new JSP file in this folder, called geolocation.jsp.

alert(“hello world”);

This JSP file will now be included by all pages that include the clickstreamcloud component. You can verify it is working by opening the Geometrixx home page and being greeted by a friendly  “hello world”.

When writing Clickstream cloud plugins, it is important to keep cachability in mind. Ideally, a Clickstream cloud plugin should not affect the cachability of the including page.

2. Getting the visitor’s location
While there are many free and commercial services for IP to geolocation resolution available, I would like to show how to use the W3C Geolocation API to retrieve the user’s location. The W3C Geolocation API is available on all modern browsers, and most importantly on all mobile browsers, it provides much greater accuracy in locating the user, because it can rely on the device’s GPS or can use GSM or Wifi triangulation. On the other hand, it will explicity ask the user for permission to locate, making the personalization of a web experience more explicit.

To retrieve the current position, and output it on the developer console (or Firebug), modify the JSP to read:

navigator.geolocation.getCurrentPosition(function(position) {

As the geo-location is fetched in an asynchronous mode, we define a callback function that will be executed, as soon as the user permits fetching the position and the device returned the position.

3. Storing it in the Clickstream Cloud
The Clickstream cloud has default stores for Profile data, Event data, Attention tag cloud data, Page data and Surfer information. The Surfer information contains technographical aspects of the visitor’s context such as Operating system and IP Address and this is also the right way to store geo-location.

Storing something in the Surfer info manager is as easy as calling


We can adjust the content of our JSP file accordingly to read
navigator.geolocation.getCurrentPosition(function(position) {

With this selection of lines, we can now build personalized, geo-targeted experiences by passing these parameters to Test&Target as MBox parameters – we can analyze the geo-related activity on our site by mapping these Clickstream Cloud variables to Sitecatalyst traffic variables or we can use them in interactive CQ components.

This entry was posted in Experience Services, Customer Experience Solutions and tagged , , , , , , , , . Bookmark the permalink.

Comments are closed.