How to manage geofencing with Batch?
Use GPS and city-level location data to send relevant messages to users near your stores, events or areas of interest.
Location is one of the strongest relevance signals for a message: a store opening nearby, a weather alert in a given city, an offer valid in a specific area. Batch provides two native location attributes, Last location and City, that you can use directly in your targeting without any additional tool.
This guide explains how to use these native attributes to build location-based orchestrations, and how to go further with real-time geofencing by connecting a location technology provider such as Woosmap.
Choose the right location signal
Batch offers two native location attributes. They answer different needs and do not have the same level of precision.
Last location
City
Source
GPS coordinates sent by your mobile app through the Batch SDK
IP-based geolocation, detected automatically by Batch
Precision
Precise (GPS), down to a radius of a few meters
City level, varies with the network connection
Platforms
iOS and Android apps
iOS, Android and Web
Freshness
Last 12 hours only
Refreshed every time the user opens the app or visits the website
Implementation
Requires a development in your app
No development required
Typical use cases
Proximity to a store, an event venue, a station
Local events, regional offers, weather-related communications
Prerequisites
Before you start, make sure you have:
For Last location: a mobile app integrating the Batch SDK, and location permission granted by your users in the app.
For City: the Batch SDK integrated in your app or website. No additional configuration is needed.
Step 1: Collect the user location
Your mobile app sends the user's GPS coordinates to Batch using the native location tracking method of the SDK. Share the following snippet with your development team:
An equivalent method is available on Android. See Tracking user location in the SDK documentation for details.
Your app remains responsible for requesting location permission from the user and deciding when to send a location, for example at app launch or when the user opens a store locator.
No action is required. Batch automatically detects the city of your users based on their IP address every time they open your app or visit your website.
If several installations are attached to a profile, Batch uses the city of the last active installation.
Step 2: Build your location-based targeting
Location attributes are available in the Query Builder, on all orchestration creation interfaces and in Segments.

See Targeting for the complete list of targeting options.
Go further with a location technology provider
The native attributes cover most geotargeting needs. Some use cases require more advanced capabilities:
Real-time triggers: send a message when a user enters or leaves a specific area, for example a store, an airport or a stadium.
Large point-of-interest networks: manage hundreds or thousands of areas, with their opening hours and attributes.
Behavioral location data: dwell time, visit frequency, home or work areas, regions visited.
Location technology providers such as Woosmap specialize in these capabilities. Their SDK monitors the areas you define directly on the device and detects entries, exits and visits. You then send these detections to Batch as events and profile attributes.
How the flow works
The event is sent to Batch
The detection is sent to Batch as an event, for example geofence_entered, with attributes describing the area, for example store_id, store_name or region. Two options are available:
From the app: your app forwards the detection to the Batch SDK with the standard event tracking methods. See Events.
From a server: the provider sends the detection to your backend, for example through a webhook, and your backend calls the Profile API.
Use the data in your orchestrations
Once location data reaches Batch, you can use it like any other custom data:
Entry in an area
Event
geofence_entered with store_id, store_name
Trigger a welcome push when the user arrives near a store
Exit from an area
Event
geofence_exited with store_id, dwell_time
Send a satisfaction survey after a visit
Favorite store
Profile attribute
favorite_store
Personalize messages with the closest store
Home region
Profile attribute
home_region
Segment campaigns by region
Notes
Location data is personal data. Collect GPS coordinates only with the consent of your users, in accordance with the applicable regulations and with the location permission settings of iOS and Android.
Last location relies on the mobile SDK and is not available on the Web. City is available on all platforms.
Last updated

