Skip to main content


Understanding the Preferred Geofences services

Suggest edit Updated on November 16, 2021

The Preferred Geofences set of services can be used to determine the most relevant set of Geofences for a particular location. For example, when a customer launches the app on their device, the app can invoke the service to determine the list of nearby Geofences to monitor. The app can then provide this list to the device’s OS to monitor, thereby avoiding having to continually poll whether the current location has tripped a Geofence.

The following two variants of the service exist:

  • HandleMktPreferredFences HTTP Service


  • HandleMktPreferredFences REST Service


Both variants expect the following inputs:

  • BaseLatitude – Latitude of the device
  • BaseLongitude – Longitude of the device
  • ClosestCount – Number of closest Geofences to return for the specified location. If this value is not provided, the system returns up to ten Geofences.

The content type for the response differs between the variants:

Service TypeResponse Content Type
HTTPtext/plain (content is still JSON)

A sample (formatted) response is shown below:

{   GeolocationArray : [{     "GeofenceName" : "PegaBedford",     "RadiusNormalized" : "1000",     "Latitude" : "42.928",     "Longitude" : "-71.464"   }, {     "GeofenceName" : "ManchesterBRAirport",     "RadiusNormalized" : "3218.688",     "Latitude" : "42.928",     "Longitude" : "-71.438"   }] }

In error scenarios, such as when the location coordinates are not provided, an error response is returned.

{   ErrorsList : [{     "pyMessage" : "Error: One or more input parameters are invalid."   }] }

The system provides out-of-the-box support for closest Geofence lookup (“Key” request parameter is set to “Closest” in the example URLs above). Custom implementations may extend this functionality to provide support for other lookup modes.

Did you find this content helpful? YesNo

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Ready to crush complexity?

Experience the benefits of Pega Community when you log in.

We'd prefer it if you saw us at our best. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us