When it comes to e-commerce websites, there are many ways to build an excellent recommendation system. For example, if a specific product is unavailable, suggesting similar alternatives or upselling is a great opportunity to maximise revenues.
But if your website offers a product or service that is tied to a location, what results should you suggest to users?
In this post, we’ll show you how to build a location-based recommendation system that ensures that only the most relevant, nearby locations are displayed to your users at the top of the search results page. To do this, we'll be using the TravelTime API.
Why use a location-based recommendation system?
A location-based recommendation system uses location information, such as journey times, within its algorithms to suggest more relevant recommendations for services, products or points of interest.
For example, when a user is searching for a hotel, job or restaurant, they will want every result to be a location that they can easily reach.
If a user must travel to get to a location, accessibility will be an important factor in their decision-making process. Simply offering similar alternatives won’t be relevant enough if they don’t meet this benchmark.
You can use a location-based recommender system to recommend similar nearby alternatives and provide the most relevant set of results for a location-based search. This also improves the user experience because it reduces the number of searches the user has to make.
Below are a few examples of how you can use location-based recommendation systems:
1. Recommending nearby hotels to book
If a user searches for a hotel in a location that is fully booked, you can suggest nearby alternatives based on how easily they can reach their desired location:
2. Recommending nearby events and activities
When a user has purchased a ticket, you can recommend similar activities nearby:
3. Recommending suitable properties near points of interest
You can use a location-based recommender system to help users find suitable properties based on travel time to points of interest and display a larger range of properties fitting the user’s criteria:
How to filter nearby location-based search results using travel times
For our example, we’ll take the use case of a hotel booking search.
Let’s say we run a hotel comparison website and a user has searched for hotels close to Amsterdam city centre. However, high demand for the dates selected and room costs mean that certain hotels aren’t available.
In this instance, you could suggest similar hotels by increasing the price per night or compromising on the star rating of the hotel. Alternatively, using a journey time similarity recommendation methodology, you could also suggest:
- Hotel 1: Zandaam, 14 minutes by train
- Hotel 2: Haarlem, 19 minutes by train
- Hotel 3: Amsterdam Oost, 11 minutes by car
This approach also allows you to test whether users are more likely to choose a hotel that may not be in the city centre, but is a) within easy reach by transport, b) cheaper, and c) has more amenities.
How to build a TravelTime API request to calculate travel times
Using the TravelTime API, it’s possible to calculate travel times from a point of origin to thousands of destination points (you can get a free API key here).
By doing this, you can then display the most relevant hotel listings – by shortest travel time – on your search results page.
In our example, we’ve used Amsterdam Central Station as the starting location. This means that every hotel will be filtered based on its proximity to this train station.
Tip: When searching for recommendations in a city that has a good public transport network, it’s a good idea to use a transport hub as the departure or arrival location. This way, the API calculates a short journey time because many transport connections service this location.
The first thing we’ll do is request out any hotels more than 45 minutes away from our chosen destination. For the most basic request you need to specify 2 things:
1. What time you wish to depart or arrive
- Use departure if users will enter the start location to discover where’s reachable from that point. E.g. find suitable restaurants near my office if I depart at 5 pm.
- Use an arrival search if you want to reach that destination at a certain time. E.g. show me airport hotels so I can arrive at the airport by 3 am.
2. Which transport mode you want to use
- Choose from public transport, cycling, walking, driving. With the TravelTime API, you can also combine modes such as ‘driving and train’ or choose to single out modes, such as bus only.
The TravelTime API also has a time window feature called Range. Since it’s unlikely that you’d need to depart from Central Station at an exact time when booking a hotel, we can use Range to calculate travel times with the assumption that the user can depart any time between 2 pm and 3 pm. This time window will cover most public transport departures in Amsterdam and will maximise the volume of results the user gets.
Below is an example showing a public transport request within 45 minutes using a 1-hour range and departing at 2 pm on Monday:
This filters all hotels that fall within 45 minutes using public transport and fit the user’s criteria. You can see the list in the following table:
If you want to increase the possible pool of hotels even further, you can request travel times for driving and cycling as well as public transport. This means each hotel will have 3x journey times listed alongside each result.
You can see the list of results in the following table:
How does the TravelTime API model work?
How we calculate public transport times
When you send a request to the TravelTime API, we calculate every possible route that the user can take. This way we can understand whether they can reach the location within their selected travel time limit.
We have a dedicated public transport data team who collect data for all public transport providers in countries where we are live.
Travel time calculations assume the user must depart their start location at a specified time, walk to a station or stop, wait for the next suitable service, take the journey, and have enough time to get off on the other side.
Our public transport models use proprietary routing models
How we calculate drive times
We’ve built a proprietary drive time model, which includes data from OpenStreetMap as well as data that helps us determine congestion during peak times or speed limits on roads. We don’t use drive times from other routing engines.
Next steps: Build your recommendation system with the TravelTime API
In this post, we've covered how to create a location-based recommendation system to recommend nearby services and points of interest using the TravelTime API.
The potential use cases for the TravelTime API are virtually endless. To learn about more possible use cases, check out our documentation.
To start building your own recommendation system for your website, you can sign up for a free API key here.