Targeting by Location (GeoLocation)

This document will outline what you will need to add to your Appcues.identify() call and how to then target by location.

*NOTE* Geolocation must be enabled by your users in order for location to be collected. Be sure to test this implementation for instances where users have and have not enabled it in their browser.

In addition, the geolocation function may timeout. We recommend ensuring that the location call has been successful before passing coordinates to the Appcues.identify call.

Below is an example Javascript code snippet to add location coordinates to your Appcues.identify call:

function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        return false;
    }
}
function showPosition(position) {
   	 return position.coords; 
}

const currentLocation = getLocation() ? getLocation() : null;

Appcues.identify('aaa-bbb-ccc', {
	currentLatitude: currentLocation.latitude,
	currentLongitude: currentLocation.longitude
})

How to target by Location:

In this example, we'll focus on the Appcues HQ right here in Massachusetts: Latitude 42.363175, Longitude -71.059233. 

Now, we're going to target our neighbors by using the area around our location. This area will be represented by a square region located inside these coordinates:

top left
42.364129, -71.063396

top right
42.364286, -71.056401

bottom left
42.360261, -71.063396

bottom right
42.360261, -71.056401

To find your own Latitude and Longitude coordinates: https://www.latlong.net/

In your desired flow's Audience section in the 'Target and Publish' step, choose 'Property' --> 'Current Latitude' --> 'greater than/ less than' ---> {insert desired latitude}

Choose the 'Add Another' green button and repeat but this time choose occured after: 'Property' --> 'Current Longitude' --> 'greater than/ less than' ---> {insert desired longitude} 

Still need help? Contact Us Contact Us