> For the complete documentation index, see [llms.txt](https://doc.batch.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.batch.com/guides-and-best-practices/orchestration/how-to-manage-geofencing-with-batch.md).

# 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](https://www.woosmap.com/).

### 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     |

{% hint style="info" %}
**Geotargeting vs. geofencing.** The native attributes let you **target** profiles based on where they were recently seen, when your orchestration runs. They do not detect the exact moment a user enters or leaves an area. To react in real time to an entry or exit, use a geofencing provider as described in Go further with a location technology provider.
{% endhint %}

### 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

{% tabs %}
{% tab title="Last location (GPS)" %}
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:

```swift
// iOS — location is a CLLocation object retrieved from CoreLocation
BatchProfile.trackLocation(location)
```

An equivalent method is available on Android. See [Tracking user location](https://doc.batch.com/developer/sdk/ios/profile-data/events#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.

{% hint style="warning" %}
The SDK throttles location tracking to preserve battery and network usage: it accepts **one location every 30 seconds**. Any update sent sooner is ignored.
{% endhint %}
{% endtab %}

{% tab title="City (IP-based)" %}
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.

{% hint style="info" %}
IP-based geolocation tends to be more accurate when users are connected to a Wi-Fi network. On mobile networks, the detected city can correspond to the location of the carrier's infrastructure rather than the actual location of the user. You can check the value detected for your own installation with the [debug tool](https://doc.batch.com/developer/sdk/ios/profile-data/debug).
{% endhint %}
{% endtab %}
{% endtabs %}

### Step 2: Build your location-based targeting

Location attributes are available in the Query Builder, on all orchestration creation interfaces and in Segments.

{% stepper %}
{% step %}

#### Open the targeting

Create a new Campaign, Automation or Segment, and go to the **Targeting** section.
{% endstep %}

{% step %}

#### Add a location condition

Click **Add condition**, then select the attribute you want to use in the **Built-in data**:

* **Last location**: define a reference address and a radius in meters. Batch targets profiles detected within this area during the last 12 hours.
* **City**: select one or several cities.
  {% endstep %}

{% step %}

#### Check the estimated reach

Review the **Estimated reach** before saving. A low reach on **Last location** usually means few users opened the app near the area during the last 12 hours.
{% endstep %}
{% endstepper %}

<figure><img src="https://509463063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfiAYaWDWqtFZeXxyg67F%2Fuploads%2FgPdSFymMLnrcaLlvQa9T%2FCleanShot%202026-10-09%20at%2017.31.15%402x.png?alt=media&amp;token=e0c6250f-b62f-48c4-b096-a5a5bf59c084" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
**Save your areas as Segments.** If you target the same areas regularly, for example your store network, create one Segment per area or per region and reuse it across your orchestrations.
{% endhint %}

See [Targeting](https://doc.batch.com/getting-started/features/customer-engagement-platform/orchestration/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

{% stepper %}
{% step %}

#### The provider detects a location event

The provider SDK, integrated in your app, detects that the user enters an area you configured, for example the surroundings of a store.
{% endstep %}

{% step %}

#### 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](https://doc.batch.com/developer/sdk/ios/profile-data/events).
* **From a server**: the provider sends the detection to your backend, for example through a webhook, and your backend calls the [Profile API](https://doc.batch.com/developer/api/cep/profiles/update).
  {% endstep %}

{% step %}

#### Batch triggers the orchestration

A **Trigger Automation** starts when Batch receives the event, and sends the relevant message on the channel of your choice: push, In-App, email or SMS.
{% endstep %}
{% endstepper %}

#### Use the data in your orchestrations

Once location data reaches Batch, you can use it like any other custom data:

| Data sent to Batch | Type              | Example                                          | Usage                                                     |
| ------------------ | ----------------- | ------------------------------------------------ | --------------------------------------------------------- |
| 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                               |

{% hint style="info" %}
**Event attributes vs. profile attributes.** Event attributes describe the detection and stay attached to the event, for example the store entered. Use them to trigger and filter. Profile attributes describe the person durably, for example the favorite store. Use them to segment and personalize.
{% endhint %}

{% hint style="danger" %}
**Control the message pressure.** A user can enter the same area several times a day. Apply a capping on your Trigger Automation and filter the events you forward, for example by limiting detections to opening hours or to a minimum dwell time, to avoid sending repeated messages.
{% endhint %}

### 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.batch.com/guides-and-best-practices/orchestration/how-to-manage-geofencing-with-batch.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
