Target by country
Country is determined by the device’s IP address and updates automatically each time the user opens your app. Use thecountry 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:Add location permissions and dependencies to your app
Configure your app’s native location permissions and include the required dependencies.
- iOS: Follow Apple’s Choosing the Location Services Authorization to Request developer guide.
- Android: Follow Google’s Request location permissions developer guide.
Enable location sharing with OneSignal
Call See the Mobile SDK reference for all platform examples.
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.Request location permission from the user
Trigger the system location permission prompt using See the Mobile SDK reference for all platform examples.
Location.requestPermission(), or use an in-app message as a soft pre-prompt for better opt-in rates.- Create segments using the
locationfilter (radius targeting). - Trigger messages using the Create message API.

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:- Request location access in your web app using the browser’s Geolocation API.
- Use JavaScript to detect the user’s coordinates.
- Send those coordinates to OneSignal using tags.
"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.
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.
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.Related pages
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.