docs/Advanced features/Geofencing
location as the trigger

Geofencing.

Geofencing sends a notification automatically when a participant enters or leaves a defined geographic area — no clock, no cron.

Geofencing lets Samply send a notification and open a survey automatically when a participant enters or leaves a defined geographic area — a workplace, a supermarket, a home neighbourhood. The trigger is the location event itself, not a clock time.

Published research

The Samply geofencing implementation is described and empirically validated in a peer-reviewed article in Behavior Research Methods:

Shevchenko, Y., & Reips, U.-D. (2024). Geofencing in location-based behavioral research: Methodology, challenges, and implementation. Behavior Research Methods, 56, 6411–6439.

https://doi.org/10.3758/s13428-023-02213-2

Three controlled studies using the Samply app yielded an overall notification sensitivity of 82.5% across 360 fence crossings. The article provides empirical guidance on radius selection, platform differences, and environmental factors — the recommendations below are drawn from this work.

How geofencing works

Once a participant joins a study with geofencing enabled, the Samply Research app registers the geofenced zones on the device and begins monitoring location in the background — even when the app is closed. When the device detects that the participant has entered or exited a zone, the app fires a local notification and records a geofencing-event in the study history.

Location processing happens entirely on the participant device. Samply never receives raw GPS coordinates. The server only records that a geofencing event occurred (enter or exit) along with the timestamp. Researchers see the event in the history log but not the absolute position.

Enabling geofencing

Open Edit study and toggle Enable Geofencing. Two configuration panels appear: one for researcher-defined locations and one for participant-defined locations. You can use either or both.

Before saving, fill in the Geofencing instruction field. This text is shown to participants when they join the study, explaining why constant location tracking is required and how you will use the data. Participants must grant background location permission to the Samply Research app for geofencing to work.

Researcher-defined locations

Enter the locations yourself — they apply to all participants equally. For each location, provide:

Latitude and longitude
The centre of the geofenced zone. After saving, markers appear on a map and can be dragged to adjust the position visually.
Radius (metres)
The circular boundary around the centre point. The participant triggers the zone when their device GPS places them within this distance of the centre.
Exit zone size (metres)
A separate, typically larger radius used to detect exits. Setting a larger exit zone than the entry zone reduces spurious exit events caused by GPS drift at the boundary.
Minimum time window (minutes)
The minimum gap between two notifications from this zone. Prevents repeated triggers when a participant lingers near the boundary and the GPS signal oscillates.
Trigger on enter / trigger on exit
Choose which crossing direction fires the notification. You can enable both.
Hide notifications but record events
Fires no visible notification but still writes a geofencing-event to the history. Use this when you want passive location-event logging without interrupting the participant.

All researcher-defined locations share the same notification content: a title, message body, and survey URL (configured in the geofencing section of Edit study). URL placeholders are supported — see URL placeholders for the full token list.

Participant-defined locations

Instead of specifying zones yourself, you can let participants enter their own locations — for example, their home address or workplace — directly in the Samply Research app. Enable participant-defined locations in Edit study and provide a default radius and survey URL.

Each participant defines zones that are private to them. The zones are registered on their device and never transmitted to the Samply server. This is the appropriate choice for studies where the target location is personal and varies between participants (e.g. "your home", "your usual supermarket").

Privacy and consent

Background location tracking is a sensitive permission on both iOS and Android. You must explain to participants in the Geofencing instruction field what location data you collect, why, and how long it is retained. This explanation is shown at study enrolment — treat it as an informed consent disclosure.

Key privacy properties:

  • Samply does not store GPS coordinates. Only enter/exit events and timestamps reach the server.
  • Participants can disable location tracking for a specific study from within the app without leaving the study.
  • Participants can stop all location tracking by disabling location permissions for the Samply Research app in their phone settings.

Geofencing events in the history

Each geofencing trigger writes a result record with event status geofencing-event and the timestamp of the crossing. These records appear in the study history log alongside scheduled notification results and can be downloaded in the CSV export. The export includes the geofencing event timestamp in the same per-event columns as notification receipt and tap events.

If you attached a survey URL to the geofencing zone, the URL is recorded in the result alongside the event — giving you a link between the location trigger and any subsequent survey completion (via the completion callback mechanism).

Empirical guidance

The following recommendations are based on the findings in Shevchenko & Reips (2024), which validated Samply geofencing across three controlled studies with 360 fence crossings.

Use a radius of at least 100 metres
A 10 m radius caused frequent misses on Android and false alarms on iOS. At 100 m, sensitivity stabilised across both platforms. Smaller radii are only reliable in open-sky environments with excellent GPS signal.
iOS outperforms Android — plan accordingly
iOS devices showed higher overall sensitivity; Android notifications tended to arrive closer to the fence boundary (the device crossed further before the trigger fired). If your study population is mixed, report platform as a covariate and consider stratifying your analysis.
Enter and exit events behave differently
Exit notifications were delivered significantly further from the boundary than enter notifications — a mean of 234 m vs. 87 m in the studies. If your design depends on capturing the exit moment precisely, set a larger exit zone radius and treat exit-event timestamps with more tolerance.
Dwell time matters
Participants who stayed at a location for at least 5 minutes showed substantially higher sensitivity than those who passed through briefly. For fleeting exposures (e.g., a bus stop), expect lower detection rates.
Forest and low-connectivity environments reduce sensitivity
Areas with poor internet connectivity (dense forest, underground spaces, rural areas with weak signal) significantly reduce sensitivity. The app relies on network-assisted GPS for zone detection; without connectivity, events may be delayed or missed entirely. Disclose this limitation in your study protocol.

Things to watch out for

Participants must rejoin to pick up zone changes
Geofenced zones are registered on the device at the time the participant joins the study. If you add or modify zones in Edit study after participants have already enrolled, they will not receive the updated zones until they leave and rejoin the study.
GPS accuracy limits effective radius
Urban GPS accuracy is typically 5–20 metres; indoors or in dense areas it can exceed 50 metres. Set radii larger than your required precision to avoid missed triggers. The exit zone setting compensates for boundary oscillation.
Background location permission may be revoked
iOS and Android can revoke background location permission at any time — after an OS update, after a device restart, or if the user changes app settings. Geofencing silently stops working when permission is missing. Remind participants in your study instructions to keep background location enabled.