Sep 24, 2021 • Blog

How to Build a Location-Based Recommendation System for an E-Commerce Website

facebook iconx icon

Contents

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

  1. Usedepartureif users will enter the start location to discover where’s reachable from that point. E.g. find suitable restaurants near my office if Idepartat 5 pm.
  2. Use anarrivalsearch if you want to reach that destination at a certain time. E.g. show me airport hotels so I canarriveat the airport by 3 am.

2. Which transport mode you want to use

  1. 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:

Hotel Public Transport Travel Times
Amadi Panorama Hotel unreachable
Amsterdam Forest Hotel unreachable
Best Western Amsterdam unreachable
Bilderberg Garden Hotel unreachable
Conservatorium Hotel 00:16:09
Corendon City Hotel Amsterdam unreachable
De L’Europe Amsterdam 00:06:54
DoubleTree by Hilton Amsterdam 00:00:00
Dream Hotel Amsterdam 00:08:55
Eden hotel Amsterdam 00:10:30
Four Elements Hotel unreachable
Hans Brinker Hostel Amsterdam 00:12:50
Hotel & Wellness Zuiver unreachable
Hotel Casa Amsterdam 00:16:02
Hotel Espresso 00:15:43
Hotel Roemer Amsterdam 00:15:10
Hotel van de Vijsel 00:14:56
INK Hotel Amsterdam 00:05:51
Jaz in the City Amsterdam unreachable
Lloyd Hotel Amsterdam 00:12:49
NH Amsterdam Schiller 00:10:12
nhow Amsterdam Rai 00:18:31
Postillion Hotel Amsterdam 00:19:05
Qbic Hotel WTC Amsterdam 00:18:13
Room Mate Aitana 00:06:22
The Lancaster Hotel Amsterdam 00:15:01
the niu Fender 00:18:35
Via Amsterdam unreachable

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:

Hotel Public Transport Driving Walking Cycling
Amadi Panorama Hotel unreachable 0:18:25 unreachable unreachable
Amsterdam Forest Hotel unreachable unreachable unreachable unreachable
Best Western Amsterdam unreachable 0:16:00 unreachable 0:19:55
Bilderberg Garden Hotel unreachable 0:13:06 unreachable 0:14:20
Conservatorium Hotel 00:16:09 0:11:44 unreachable 0:10:50
Corendon City Hotel Amsterdam unreachable 0:16:30 unreachable unreachable
De L’Europe Amsterdam 00:06:54 0:08:07 00:18:44 0:04:56
DoubleTree by Hilton Amsterdam 00:00:00 0:16:37 unreachable unreachable
Dream Hotel Amsterdam 00:08:55 0:10:37 unreachable 0:06:55
Eden hotel Amsterdam 00:10:30 0:08:21 unreachable 0:06:52
Four Elements Hotel unreachable unreachable unreachable unreachable
Hans Brinker Hostel Amsterdam 00:12:50 0:09:43 unreachable 0:07:55
Hotel & Wellness Zuiver unreachable unreachable unreachable unreachable
Hotel Casa Amsterdam 00:16:02 0:15:41 unreachable 0:16:02
Hotel Espresso 00:15:43 0:09:43 unreachable 0:10:24
Hotel Roemer Amsterdam 00:15:10 0:10:30 unreachable 0:10:00
Hotel van de Vijsel 00:14:56 0:10:20 unreachable 0:09:45
INK Hotel Amsterdam 00:05:51 0:05:21 00:09:26 0:02:32
Jaz in the City Amsterdam unreachable unreachable unreachable unreachable
Lloyd Hotel Amsterdam 00:12:49 0:08:45 unreachable 0:09:38
NH Amsterdam Schiller 00:10:12 0:09:57 unreachable 0:06:26
nhow Amsterdam Rai 00:18:31 0:15:38 unreachable 0:18:16
Postillion Hotel Amsterdam 00:19:05 unreachable unreachable unreachable
Qbic Hotel WTC Amsterdam 00:18:13 0:15:31 unreachable 0:18:21
Room Mate Aitana 00:06:22 0:04:19 00:14:20 0:03:57
The Lancaster Hotel Amsterdam 00:15:01 0:09:38 unreachable 0:08:24
the niu Fender 00:18:35 0:11:25 unreachable 0:14:02
Via Amsterdam unreachable unreachable unreachable unreachable

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 routethat 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.

Public transport coverage_TravelTime

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 cansign up for a free API key here.

facebook iconx icon

Contents

Display more relevant, personalised search results with the TravelTime API

Get started free
cta accent icon