Skip to main content
Location-based segmentation lets you send messages based on where your users are. OneSignal can segment users by country, GPS coordinates, or custom tags — so you can create timely, relevant outreach based on physical location. As users interact with your app and location tracking is enabled, their coordinates update in near real time and can be used to send messages via Journeys or any message creation tool.
OneSignal does not track GPS location by default.The SDK never collects latitude or longitude unless your app (1) has the correct permissions and dependencies, (2) explicitly enables sharing with OneSignal, and (3) the user grants location permission. See Location tracking setup below and our blog post You’re in Control: How Location Actually Works in OneSignal’s SDK for more details.

Target by country

Country is determined by the device’s IP address and updates automatically each time the user opens your app. Use the country data filter in Segments or the API filters parameter.

Target by location (latitude, longitude, and radius)

If your mobile app collects GPS location and shares it with OneSignal, the SDK updates the user’s coordinates approximately every 5 minutes (based on permission and system rules). If the app is force-stopped, location cannot be tracked until the user opens it again.

Location tracking setup

Tracking location requires three steps:
1

Add location permissions and dependencies to your app

Configure your app’s native location permissions and include the required dependencies.
If you see the error LocationManager.startGetLocation: not possible, no location dependency found, your app is missing the required location dependency. A common fix for Android is to add the Google Play Services location library in your app/build.gradle:
implementation 'com.google.android.gms:play-services-location:21.0.1'
2

Enable location sharing with OneSignal

Call Location.setShared(true) to allow the SDK to send the device’s coordinates to OneSignal. Without this, your app will not send location data to OneSignal.
OneSignal.Location.setShared(true);
See the Mobile SDK reference for all platform examples.
3

Request location permission from the user

Trigger the system location permission prompt using Location.requestPermission(), or use an in-app message as a soft pre-prompt for better opt-in rates.
OneSignal.Location.requestPermission();
See the Mobile SDK reference for all platform examples.
Once location tracking is enabled, you can:
  • Create segments using the location filter (radius targeting).
  • Trigger messages using the Create message API.
OneSignal segment builder showing the location radius filter with latitude, longitude, and radius fields

Web push latitude and longitude tracking

OneSignal does not collect latitude/longitude for web. However, you can use tags to set the location from your web app or use the Update User API to set the location from your server. Tagging example:
  1. Request location access in your web app using the browser’s Geolocation API.
  2. Use JavaScript to detect the user’s coordinates.
  3. Send those coordinates to OneSignal using tags.
OneSignal.User.addTags({
  lat: "37.160",
  long: "-117.773"
});
Once the tags are set, create geofenced segments using range filters: Example segment: Tag "lat" > 37 AND "lat" < 38 AND "long" > -118 AND "long" < -117

Target by city or custom location

OneSignal does not natively detect city or area codes. To target by city or custom location:
  • Let users input a city or region in a form.
  • Or use JavaScript with reverse geocoding (e.g., Google Maps API) to infer city from coordinates.
  • Send the city name as a data tag.
OneSignal.User.addTag("city", "San Francisco");

Geofencing with Radar

OneSignal supports advanced geofencing through Radar, a leading geolocation platform. With Radar’s SDKs and APIs, you can:
  • Trigger notifications when users enter or exit defined areas.
  • Track delivery and pickup activity.
  • Verify presence at a location.
  • Power store locators, location-based offers, and more.
To get started, visit the Radar integration docs or contact Radar for onboarding support.

FAQ

Does location tracking work on web?

OneSignal does not collect GPS coordinates from web browsers. To use location-based segments with web push, collect coordinates from the browser’s Geolocation API and store them as tags. See Web push latitude and longitude tracking above.

Why is my app not tracking location?

Verify all three setup steps are complete: location permissions and dependencies are added to your app, Location.setShared(true) is called, and the user has granted location permission. If you see LocationManager.startGetLocation: not possible, no location dependency found, add the play-services-location dependency to your app/build.gradle. See Location tracking setup for details.

How often does the SDK update location?

When location tracking is enabled, the SDK updates coordinates approximately every 5 minutes while the app is in use. If the app is force-stopped, location updates pause until the user opens the app again.

Can I target users by city?

Not natively. OneSignal tracks country (via IP address) and GPS coordinates (via the SDK), but not city or area code. You can infer city from coordinates using a reverse geocoding service and store it as a tag. See Target by city or custom location.

Mobile SDK location reference

Full API reference for setShared(), requestPermission(), and location event listeners.

Location opt-in prompt

Use an in-app message as a soft pre-prompt before requesting native location permission.

Segments

Create audience segments using location filters, tags, and user properties.

Radar integration

Advanced geofencing, trip tracking, and location verification through Radar.