Have you ever wondered how Netflix knows which country you’re in, or how an iOS app lets you match with singles in your area? These providers are using geolocation, a measurement that refers to the geographic location of any internet-connected device.
Geolocation data is collected over time to determine and map the geographic coordinates of a device’s current position. It’s how you can tag locations and timestamps on social media, log running distances with your smart watch, or see where your car is parked on Google Maps.
Real-time geolocation tracking is an important advancement in technology, and it plays a role in many mobile resources we take advantage of every day—like driving directions, delivery apps, and banking services. Geolocation services also boost user experience by enabling businesses to better serve their customers’ specific needs, increase engagement, and improve online communities.
It can be useful to deploy a geolocation API in the backend of your application; it assists with services like location tracking, contextual advertising, and more. These APIs allow you to build location-aware web applications that take advantage of the information in real time.
In the following guide, we will discuss:
How geolocation works
Benefits of and use cases for tracking location information
Data privacy and security
Reasons to use a geolocation API for your web application
Geolocation is a “best guess” set of coordinates, made using algorithms and based on data that has been collected over time. Geolocation tracking uses a variety of methods to determine a user’s location, such as their IP Address, Global Positioning System (GPS), WiFi, cellular networks, RFID, and user input. It is most common for applications to use more than one of these tools when calculating geolocation, in order to avoid some of the shortfalls of each specific method.
Device-based geolocation most commonly depends on cellular networks, WiFi, and GPS to determine location. It triangulates these signals to pinpoint a device’s physical location, and can be very accurate. However, because this method relies on different broadcasts and signals, it is most accurate in areas with higher population density. In more rural areas with less cell towers, there can be delays and the data can have a wider margin of error.
IP-based geolocation data has been mined over time by third party providers. Internet service providers (ISPs) assign an IP address to every device that connects to the internet—a unique address that signifies their specific device. IP addresses have been stored in databases with geographical locations allocated to them. IP geolocation is only as accurate as the data within these databases. Inaccuracies can arise due to incorrect entries, encryption via VPNs, and more.
In the United States, IP geolocation can be up to 90% accurate at the country and state level, but at the city-level accuracy drops between 50-70%, depending on the source. So a website may correctly approximate that you are in New York, but not that you are upstate in Buffalo. One of the most common methods to improve accuracy is to request user input, like when a form prompts a user to enter their address or zip code.
A Geolocation API let’s users share their location data to improve their experience with a service. Geolocation APIs are a communication interface between a client and service that returns information about the client’s geographical location. They provide information like IP geolocation and coordinates, time zones (UTC), types of currency, region, and more. With a Geolocation API, you can integrate location with other data sources to improve system efficiency and automate more processes.
All major web browsers (like Firefox, Chrome, and Safari) support Geolocation APIs, and it is also used on mobile operating systems such as Android, iOS, and Windows.
getCurrentPosition() – Retrieves device location data and stores the coords (latitude + longitude), altitude (if available), and accuracy in a Position object which can be used in a callback function. Optional arguments can be set to specify: 1) an error callback and, 2) the desired level of accuracy, the timeout value, and the maximum age to cache position data.
watchPosition() – Starts a watch operation that adds the current position to a Position object. It also polls for system events that indicate any changes in location. When new location data is available, the Position object is updated to reflect the new position. As in getCurrentPosition(), one can optionally set an error callback and extra options (like accuracy, timeout, and max age).
clearWatch() – Stops an ongoing watch operation specified by the operation's WatchID. WatchIDs are originally assigned to a watch operation when calling the watchPosition() method.
Geolocation tracking doesn’t just show current locations—it gives valuable insights you can analyze over time and use to grow your business. You can use geolocation data to target marketing efforts in different regions, expand your company to a specific area based on interest, or build out specific sites for the countries where you receive most traffic.
Knowing a user’s location can also help foster communities and improve services. With the prevalence of everything from on-demand services to IoT devices, customers expect quick updates that are relevant to them. If they use an app to search for a nearby restaurant in New York, they don’t want to be shown options in Tennessee. Geolocation data tailors information to specific users and ensures they are getting the best results.
Gathering device-based location information is beneficial for a wide range of businesses, especially in fields that offer real-time services. Companies can send updates to customers, keep maps updated in real time, and tailor information to meet unique requests. Some of the most common use cases are rideshare apps, targeted marketing, and financial services, but there are so many great innovations using geolocation data that aim to make daily life more convenient.
Using geolocation data, apps are able to update customers with their driver’s location and provide directions to their drivers in real time. Geolocation can also help to confirm a delivery will be on time or that a package has been delivered.
Geolocation helps transportation companies keep track of their fleet easily, either through real-time tracking on the road or after-hours tracking using geofences. Tracking high-value assets like vehicles or construction equipment helps ensure their safety and prevent loss.
Using location data, banks are better able to detect possible fraudulent activity and notify consumers of issues. For example, it is suspicious to receive a debit charge from a store in Buenos Aires if you are based out of San Francisco. A bank would be able to alert you because of your geolocation, and confirm if the charge was indeed fraudulent.
Geolocation-equipped devices such as wearables, smartphones, or home security systems can be easily located, which optimizes the devices and enables many useful features.
Geolocation is a powerful marketing tool. Tracking a user’s location can enable companies to promote sales or suggest relevant products based on consumers’ location history. With this location history and data, companies can analyze their base and make more informed decisions.
Geolocation is commonly used in law enforcement to detect possible criminal activity online, such as money laundering or phishing scams. It is also used in monitoring devices, like ankle bracelets.
Many iOS and Android apps use location data to customize content geared towards their users’ specific needs. Business review apps, dating apps, and more are all improved by using location-based services, as it specifies the results to their users’ surroundings.
Have you ever heard of Pokemon Go? That game—and many other location-based games like it—uses geolocation services to make their gameplay more interactive and engaging. Location-based games work off the user’s location to load different maps, levels, and items, therefore extending gameplay into the real world.
While the benefits of geolocation make our daily lives easier, the idea of devices being tracked can understandably make some people uneasy. It could potentially put people at risk for their location data to be known to others. For this reason, many protocols have been developed to make users feel safe, such as requiring permission for a web application to collect data.
Some people also worry about the risks of being “monitored,” so it is important to note that geolocation does not track people, only the position of the device. For example, if you leave your phone in the car to run errands, the geolocation will not update during that time.
Applications are required to receive user permissions before they are allowed to track or share location data. It was not always required for websites to ask the same permissions when utilizing IP geolocation to track data, since this form of geolocation is less accurate.
However, many websites now ask for permission to track data in order to comply with the EU’s protection laws that went into effect in 2018, known as GDPR. Web browsers also employ different methods to ensure user safety, such as requiring the HTML5 Geolocation API to only run when a connection is secure.
It is also becoming more common for internet users to employ VPN’s, which route IP addresses through proxy servers, obscuring location and offer a layer of data encryption. This makes geolocation services less accurate but can contribute to a feeling of safety for consumers.
Now that you know why geolocation is beneficial, how should you take steps to build it into your app? Should you go with a third-party geolocation API or location tracking service, or build out this functionality on your own?
A third party geolocation provider, like PubNub, can also act as a database, along with other benefits like mapping in real-time, matching services based on location, and optimizing routes by enhancing geolocation with third-party data.
Maintaining and operating a geolocation database is intensive, and using a backend platform for location tracking can help save immensely on development time and maintenance costs for the network. Building and integrating a custom real-time network for location services is only part of the process. Scaling and maintaining that network is another.
Using PubNub’s Geolocation API and data-streaming can also help to ensure scalability and reliability. For example, when One Call implemented PubNub to power real-time updates between patients, drivers, and administrators, their web application, RelayRIDE, was able to launch faster, scale to handle rapid growth, and exceed technical expectations.
Geolocation data and Geolocation APIs are valuable business tools. Knowing a user’s location and history helps to optimize processes, gather insights, and improve experiences.
PubNub equips users to stream location data to other devices within a network or on an application. Using Pub/Sub messaging for geolocation, you can easily complete a wide range of tasks, ranging from displaying driver locations on real-time maps, to monitoring a transportation fleet, or even tracking the locations of endangered animals at a national park.
If you are interested in using PubNub to power your real-time location-based service, contact our sales team.