What is a geofence?
A geofence is a virtual fence or a perimeter around a physical location. Geofencing is a tool to connect the virtual experience with the offline world’s physical location. When an object enters this area, something happens. Easy way to think about it a fence around your home. When someone enters your yard, the burglar alarm is activated. What should happen in such circumstance? You probably want to send an alarm to the security company? Send an SMS to you? Start the burglar alarm?
Typically the geofencing use cases are not that brutal. Geofencing is a term that can be used in many different contexts, but the most popular one is the ability to detect a phone entering the area, and triggering something either in the device itself – or somewhere externally. For example, when you walk past your favourite grocery store, you get a discount coupon. This mobile-based geofencing is also the use case this blog post is focusing on. Geofencing does not require you to build anything physical in the real world – it all happens digitally. In essence you draw an area on top of map and define in your code what you want to happen, when someone walks into that area. That being said, in some cases you might want to add some hardware in the real world to improve the positioning accuracy, but more of that later on in the post.
How does geofencing work?
Typically geofencing is thought as something that only works outdoors, utilizing GPS technology. But actually, you can use it with any technology. Depending on your use case and the accuracy you need for it, you could utilize a range of positioning technologies, such as: Wi-fi, GPS, cellular data, geomagnetic and Bluetooth beacons. What technology or technologies to use, depends a lot on where the geofencing will happen. In outdoors for larger geofences you could get good results with cellular and WiFi data, which gives better battery efficiency than GPS. Indoors you would need WiFi, Bluetooth or geomagnetic information to bring the fine-detailed accuracy required for entrance events to small geofences.
The great thing about geofences is that you can define them anywhere you want. Around your store, around your city, around your partners’ locations – and even around your competitors’ locations. GPS, cellular and WiFi data are available aplenty from Google and Apple databases (so-called native positioning), which means that you don’t have to do any mapping work yourself.
Geofencing works the same way anywhere you are, is it indoors or outdoors. The basic principal is that you define the areas that you are interested in, start listening to the phone’s position updates and compare those to the geofences. The great thing is that you do not need to hard-code this into your application, but there are some great platforms that handle all of this for you. Advertising warning: Proximi.io platform is one of them – a geofencing platform built with API-first principles for heavy users.
What does it require?
An app – very important to note that geofences for 99,9% of the use cases cannot be used without an app. There are some minor exceptions, but most likely, if you are reading this blog post, you will need an application – whether your own or through a partner – that can be utilized for this purpose. This application needs to be installed by all of those people, whom you want to detect entering or exiting your store.
Location permission – In order to receive position updates, the application needs to have a permission for utilizing the user’s location. This is a user-selectable option, which makes it important to provide a good explanation for the user of the benefits they will get of enabling their location.
On Android you can select between coarse location (approximate location) that only utilizes cell tower and WiFi access point data for determining position; and fine location (precise location) that uses a combination of the above and GPS data to determine the position. More on the Android development documentation.
On iOS you can select between when-in-use or always access permission. If you want your geofencing to function in the background, the second option is required. More information can be found in the iOS developer documentation. As you will probably also be interested in triggering geofences, when the app is not currently in use, remember to plan a workaround for that for both platforms.
What are the limitations?
Indoor setup – In case you are interested in detecting small geofences indoors, you will need a bit of preparatory work in the venue. You will need to either have those areas mapped for WiFi or geomagnetic coverage, or Bluetooth beacons installed. If you use Bluetooth beacons, remember to also ask for permissions for Bluetooth.
Background functionality – Geofencing in the background is crucial to many projects, people generally don’t walk with their phone or apps open all the time. Background functionality differs with Android and iOS, but both have options to achieve the desired geofencing capabilities – you can see our blog post on “Will my geofencing function in the background” for more details.
Size – The size of a geofence typically raises some questions, how small can I go – or what is the maximum size of the geofence. There is no limit to how big a geofence is. You could even geofence the entire Earth, but then you could just send the same notification to all the app users in bulk, regardless of their position. Geofencing entire countries, cities or neighborhoods is a perfectly valid use case.
The minimum size depends on the technologies utilized, and also a bit on the physical location and the accuracy of GPS/WiFi data there. If you are just using native positioning, a good way to test the minimum size possible for your geofence by walking around in the area and look at the positioning accuracy in Google or Apple Maps. That is the same native positioning data as your application will be utilizing. In some locations the minimum recommended radius could be 20-50 metres, sometimes you could go over lower. In no circumstance you should go under 5 metres radius with native positioning, as the ability to trigger it comes unstable. When beacons or other indoor positioning setup are added in the picture, you could go as low as 2 meters. This size would ensure there is no unnecessary bouncing in and out of the geofence. A common use case like geofencing different rooms, is quite nicely achievable.
Shape – A standard geofence is circular in shape, but polygon shape geofences are also possible to create. There are some limitations to what shape is recommended – for example when you want to add a geofence around a single beacon, circle is the optimal shape. It is also worth noting that the calculating that is required for detecting polygonal geofences is much heavier, so it will not be as fast or reliable as with circular shapes.
Amount – Both Android and iOS native SDK’s offer a method for hard-coding geofences into an app. The limitation for iOS SDK is maximum 20 different geofences or regions that the application can detect. The same applies for Android, but the limit for geofence amount is 100 geofences. Using an external geofencing platform is one easy way to go over this limit. The Proximi.io platform has built-in automation for rolling the geofences the app is listening to at any one point, making it possible to listen to an endless amount of geofences.
Battery consumption – When building your application, you will need to plan for a careful balance between the accuracy, background functionality and battery consumption. Unavoidably, the battery consumption in your app will increase a bit when you activate location services, but with well-designed positioning stack the increase will not be disturbing to your app users.
How to use geofences?
How are geofences then used? In summary, there are five main things that you can do, when a geofence enter event is detected:
- Send a push notification
- Display visual content and media in the app
- Gather analytics (in the background)
- Verify entry/exit
- Trigger something in a 3rd party API
Here are some potential use cases in real life:
- Send a lunch offer, when you walk by a restaurant around midday
- Display information about museum items, when you walk in the exhibition
- Calculating how many students are in a classroom
- Collect points by visiting different stores
- Check if the meeting room is empty
- Turn on lights, when you enter a room
Get started with geofencing!
Imagination is the limit of how what you can do with geofences. A fast, scalable and flexible way to get started is the Proximi.io platform.
What’s the benefit of using our platform:
- Unlimited amount of geofences, size and shape
- ability to edit the geofences on-the-fly and getting over the native amount limitations
- analytics – visiting amounts, visiting frequency, dwell times and heat maps
- Ability to choose one or multiple technologies all in combination
If you want to share some ideas and toss them around, we are always up for a brainstorming session: https://proximi.io/contact-us/