Location-based messages
Learn how to target users with location-based messages using OneSignal. Set up segments by country, coordinates, or geofencing with optional integrations like Radar.
Overview
Location-based segmentation allows you to send messages based on where your users are. OneSignal can segment users by Country, GPS coordinates, or custom tags which can be used to create timely, relevant outreach based on physical location.
This guide explains how to configure segments by the available location options. As users interact with your app, their location data is updated in near real time and can be used to send messages via Journeys or any of our message creation tools.
Target by country
Country is tracked based on the IP Address. This will automatically update each time the user opens your app.
Use the country
Data Filter in Segments or API filters
.
Target by location (latitude, longitude, & radius)
If your mobile app collects GPS location and shares it with OneSignal, our SDK updates the userβs coordinates approximately every 5 minutes (based on permission and system rules).
Your app must be setup to both:
- Share location updates with OneSignal
- Request and receive user permission to access location data
See our Mobile SDK location guide for setup details.
Once location tracking is enabled, you can:
- Create segments using the
location
filter (radius targeting). - Trigger messages using the Create message API.
Location filter in Segments
Web push latitude and longitude tracking
OneSignal does not collect latitude/longitude for web-only users or users that do not have location tracking enabled for your mobile app. However, you can use data tags to set the location from your web app or use the Update User API to set the location points from your server.
Tagging example:
- Ask for location access in your web app. Here is a great Medium Post about this.
- Use JavaScript to detect the userβs coordinates.
- Send those coordinates to OneSignal using Data Tags.
Example using sendTags
SDK method:
Once the tags are set, you can create geofenced segments with range filters like so:
Example Segment: Tag "long" > 37 AND "long" < 38 AND "lat" > -118 AND "lat" < -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/region in a form.
- Or use JavaScript + reverse geocoding (e.g., Google Maps API) to infer city from coordinates.
- Send the city name as a Data Tag.
We have also partnered with Radar to enrich and automate location tracking.
Target based on a Geofence (Radar Integration)
OneSignal supports advanced geofencing through Radar, a leading geolocation platform.
With Radarβs SDKs and APIs, you can:
- Trigger notifications when users enter/exit defined areas.
- Track delivery/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.
You can now send location-based messages. Automate with Journeys or create one-off messages.