A user's location is one of the most powerful personalization tools in the digital marketer's toolbox, but the technical implementation of location services varies based on the needs of accuracy, user involvement, and device permissions.
There are two common means of getting a user's location: geolocation and GeoIP. I've seen a lot of confusion around what these terms mean, and worse, I've seen them used interchangably without an understanding of the nuances between them. Let's quickly take a look at each and set the record straight on the terminology, then see how these apply to Sitecore.
Geolocation
More broadly, "geolocation" is an umbrella term that covers the whole concept of identifying a user's geographic location. A geolocation is usually represented by a set of coordinates (typically latitude/longitude), and can be obtained by several forms of estimation (e.g. time of day), radar, or via networking protocals.
From the perspective of a modern web developer, however, the term "geolocation" typically refers to a specific JavaScript API named - you guessed it - Geolocation. This API has been available across all major browsers long enough to be reliably used today:
// Callback to handle the location information provided
function processLocation(position) {
if (position) {
console.debug(`Latitude: ${position.coords.latitude}`);
console.debug(`Longitude: ${position.coords.longitude}`);
}
}
// Requests the specific location of this navigator (browser, device, etc.)
navigator.geolocation.getCurrentPosition(processLocation);
Key points to keep in mind about the Geolocation API:
- The Geolocation API operates on the client side of an application (such as a web browser).
- Most modern browsers will prompt the user for permission to share his or her location. This presents a barrier for applications, in that users can easily decline to share their location.
- With GPS modules on most phones, the location data is hyper-accurate (typically within a few meters).
- If a user's GPS can't provide a reliable location, other geolocation sources may come into play (WiFi-based location, cellular triangulation) and may be less accurate.
GeoIP
The "IP" in GeoIP stands for internet protocal. In more specific terms, it refers to the use of a device's IP address to determine location. At a technical level, an IP address doesn't have any location information associated with it.
So how can we get location information from an IP address? To simplify: when IP addresses are assigned to an internet service provider (ISP) and subsequently a customer of that ISP, there is some location data tied to that IP address via business records. Maybe it's a specific address, maybe it's a neighborhood or apartment complex. It might even just be a city. This information is then aggregated by companies into databases that make looking up the location of an IP address relatively trivial.
Here's an example of data provided by a GeoIP lookup:
Key points to keep in mind about GeoIP:
- It almost always operates on the web server hosting a website. This means you can utilize location information while rendering a web page.
- Location obtained from GeoIP will
alwaysusually be less accurate than the Geolocation API. (There are cases where a GeoIP lookup can be as accurate as geolocation - I'll cover that in a future article. Thanks to Grant Killian for keeping me honest.) - Using GeoIP with mobile users can be particularly problematic, since their IP addresses may be dynamic and change based on which cell tower they are connected. This can throw off accuracy by hundreds of miles.
GeoIP and Sitecore
So as Sitecore developers and marketers, why do we care about the difference between "geolocation" and "GeoIP?"
Sitecore advertises and provides GeoIP services built right into the Experience Platform product. Again, this is GeoIP and not the client-side Geolocation API. With Sitecore 8 and 9, we can flip a couple of switches and have GeoIP-based location services working very quickly. Conversely, a client-side geolocation implementation will require custom development (i.e. time and money).
While there are a few implementation gotchas when using GeoIP in Sitecore (stay tuned for a future article), it's still a good starting point for using location as a means of personalization or advertising on your websites.
When talking about Sitecore location services with business stakeholders or with developers, be sure to set the standard on terminology so everyone is talking about the same technologies. Business might ask for "geolocation services" in reference to "GeoIP" - it's a small thing, but getting this correct from the start will help with architectural decisions early in a development cycle.