Geolocating your visitors

While not a first-class feature of RightMessage, many of our customers have asked about geolocation.

This guide walks you through how easy it is to personalize based on geolocation.

IP address vs HTML5 geolocation

When it comes to geolocating visitors on your website, you have two options:

  1. IP address. This simply looks at the IP address of the visitor and tries to infer where they are. This can work fairly well for country or maybe even region/state/province segmentation, but doesn’t always work locally. Many geolocated IPs show the closest big city as the location – which is usually where the visitor’s internet service provider is based. IP address geolocation happens without the visitor knowing they’re being geolocated.
  2. HTML5. You’ve probably seen “Do you want to share your location with this website?” prompts from your web browser. This type of geolocation is super precise, yet it does interrupt the visitor – at least until they give their consent. This is a consent-based and the visitor must click “Accept”.

Geolocating users based on their IP address

Follow our guide for installing your custom tracking script, but instead have our tracking script load within the following loadRM() function.

Geolocating users using HTML5 geolocation

This sample code is coming soon.

Creating segments around location

You can personalize (change images, text, etc.) per your location segments the same way you’d personalize for any other segment data. See our guide to creating auto-segment rules for more information.

You’ll want to add JavaScript variables rules that reference the data you expose to your page (after successfully geolocating.) If you’re using the script examples above, this would be:

{
    "ip": "161.185.160.93",
    "hostname": "161.185.160.93",
    "type": "ipv4",
    "continent_code": "NA",
    "continent_name": "North America",
    "country_code": "US",
    "country_name": "United States",
    "region_code": "NY",
    "region_name": "New York",
    "city": "Brooklyn",
    "zip": "11238",
    "latitude": 40.676,
    "longitude": -73.9629,
    "location": {
        "geoname_id": 5110302,
        "capital": "Washington D.C.",
        "languages": [
            {
                "code": "en",
                "name": "English",
                "native": "English"
            }
        ],
        "country_flag": "http://assets.ipapi.com/flags/us.svg",
        "country_flag_emoji": "🇺🇸",
        "country_flag_emoji_unicode": "U+1F1FA U+1F1F8",
        "calling_code": "1",
        "is_eu": false
    },
    "time_zone": {
        "id": "America/New_York",
        "current_time": "2018-09-24T05:07:10-04:00",
        "gmt_offset": -14400,
        "code": "EDT",
        "is_daylight_saving": true
    },
    "currency": {
        "code": "USD",
        "name": "US Dollar",
        "plural": "US dollars",
        "symbol": "$",
        "symbol_native": "$"
    },
    "connection": {
        "asn": 22252,
        "isp": "The City of New York"
    },
    "security": {
        "is_proxy": false,
        "proxy_type": null,
        "is_crawler": false,
        "crawler_name": null,
        "crawler_type": null,
        "is_tor": false,
        "threat_level": "low",
        "threat_types": null
    }
}

Segmenting everyone in the United States is then as simple as creating an auto-segment rule where location.country_code is equal to “US”.

Adding location information to your pages

You can also output location content directly to a page (“Hello, London!”) using Liquid templating.

Create a segment called something like “Has Location” (where, e.g., the location.city value doesn’t equal “”), and then create a personalization campaign that targets it.

Find the text you want to change, and set it to “Hello, {{ js.location.city }}!”

Next up

Synchronizing contact data with your ESP/CRM

RightMessage can automatically send segmentation data, captured either through behavior or survey responses, directly to your integrated ESP/CRM.