Available since version 2.0.0, Pilgrim SDK allows geofencing around a configurable set of venues or points. Geofences can be set for the venues, categories, or chains of your choosing. By default, Foursquare will use its knowledge of the venue’s location to return the right fence for a given place. You may also configure a radius of your choosing, but we recommend letting Pilgrim pick the right one to give you the optimal experience.
In SDK version 2.2.0, support for polygon shapes and arbitrary latitude/longitude points is also available. This allows greater customization and removes the reliance upon geofencing only Foursquare venue locations.
Why use Geofences
For use cases that rely on accuracy, regular Pilgrim SDK place visit detection is superior to geofencing. However, there are certain instances where geofencing is preferable:
When speed and proximity to a specific subset of venues is more important than accurately detecting visits there.
When it’s more important to know if a user is nearby a certain place rather than visiting.
When you want to track when users that are en-route to a specific venue, and you want to know as soon as they arrive.
Geofencing runs independently alongside regular Pilgrim SDK visit detection so you can still get the benefit of understanding everywhere your users go while enabling additional use cases.
Geofences have five potential event types that are delivered directly to the client and through an optional webhook:
Triggered on the first GPS signal that is received inside of the geofence.
Triggered after the user has “dwelled” within the geofence for a configurable length of time. Default is 1 minute.
Triggered when the device has dwelled inside a geofence radius and confirmed a stop at the venue within the radius. Only available in SDK versions 2.1.2 or greater
Triggered on the first GPS signal that is received outside of the geofence.
Triggered when the device is in a geofence radius during a get location request. Only available in SDK versions 2.1 or greater
To receive geofence events on the client, add the event handler below:
Geofences will need to be set to a specific Foursquare venue, chain, category or shape (see below). For example, a partner could set up geofences for Foursquare HQ, all coffee shops, and all Chick-fil-a’s. You can also set up a geofence for an arbitrary lat/lng or custom polygon shapes. For Foursquare venues, this means that some venue harmonization may need to take place beforehand if you already have a specific list of places you want to geofence.
Note: Geofences are set up globally across all users of the app. User specific geofences are not yet something we provide.
A geofence event will contain the following:
entrance, dwell, venueConfirmed, exit, or presence.
Same as regular pilgrim venue object.
Array of categoryIDs used by triggered geofence.
Array of chainIDs used by triggered geofence.
String of harmonized venueId.
Object containing location information about the geofence event.
Unix/epoch timestamp in milliseconds of when the event occured.
Geofences can be managed through the Geofence builder in your Pilgrim developer console or via our Geofence API.