Skip to content

How do Top Sites (Shortcuts) work?

lmarceau edited this page Sep 13, 2023 · 14 revisions

Top sites are the sites that appear in the first section of the homepage as tiles. They are mostly used as shortcuts for users to quickly access their favorite sites, or show their most visited sites.

Top sites tiles type

There are currently a total of four different tile types in Top Sites:

  1. Google tile
  2. Default suggested tiles
  3. Pinned tiles
  4. Sponsored tiles
  5. Frecency tiles Each tile type has precedence over other types, depending on the number of tiles we can show on a device.

Telemetry

There's different telemetry collected for tiles. Example with this Looker dashboard.

  1. Google refer in this case to the Google tile
  2. History-based refers to the Frecency tiles
  3. Sponsored refers to the Sponsored tiles
  4. Suggested refers to the Default suggested tiles
  5. User-Added refers to the pinned tiles More context is given on all tiles below in subsequent sections of this page.

Top sites layout

The layout of the top sites section can change depending on the device it's shown in. There's two major factor affecting the number of tiles that will show:

  • The user preference on the number of rows, which can be set from the Settings menu
  • The device's screen width. Each tile space has a fixed width, and so we calculate the number of tiles that can fit inside a certain screen width to know how many tiles can show. When the layout of the homepage is setup, and we know how many tiles we can show, we can then go down the path of figuring out which tiles have precedence over which tiles.

iPhone

Normally, on iPhone portrait mode there will be 4 tiles per row. The number of row by default is of 2, so most iPhone users will see 8 tiles. If they rotate to portrait, there should be around 8 tiles per row, which means 16 tiles total if the default number of row is set.

iPad

On iPad the number of tiles per row can vary by a significant amount, since the user can have different device size which will amount to a different number of tiles per row. The user can also go in multitasking mode which could potentially resemble the number of tiles an iPhone user can get.

Tiles precedence

Google tile

The google tile is always the first tile to show in the section. It shows up as a pinned tile. It will be added if there's enough space to show. It will not be added if there's a greater number of pinned tiles than the number of tiles we can show. Once added, it will continue to be shown until the user decides to remove it (by long pressing on the tile a menu appears which enables the user to do so). The GoogleTopSiteManager manages this tile. Google tile has precedence over sponsored tiles and frecency tiles.

Pinned tiles

A user can add pinned tiles in their top sites by visiting a website and selecting "Add to Shortcuts" from the menu. The user can also remove a pinned tile by long pressing the tile and selecting the related action for that. Pinned tiles have precedence over sponsored tiles and frecency tiles.

Pinned tiles data comes from the TopSitesProvider. Any tiles that is pinned by the user gets saved inside the SQLHistory database. Any time a user removes a tile, it respectively gets removed from that database.

Sponsored tiles

Sponsored tiles will be shown to users by default, but the feature can be turned off in the settings by disabling "Sponsored Shortcuts" under "Shortcuts" in the Homepage settings menu. There's currently a maximum of 2 sponsored tiles that can show in the Top Sites section. Sponsored tiles can only show if there's enough space remaining after pinned tiles and the Google tile are accounted for. We can only add a sponsored tile if its site is not already in a pinned tile. We make this verification using the domain without eTLD (so if amazon.com is a pinned tile, amazon.ca cannot be shown as a sponsored tile). Sponsored tiles have precedence over frecency tiles.

Sponsored tiles data comes from the ContileProvider, which calls a Mozilla API to get its sponsored tile data. Once tiles are received, data is cached for an hour.

Sponsored tile notes

We make sure no sponsored tiles click information appears in the following sections of the homepage:

  • Top sites
  • Jump back in
  • History Highlights (Recently saved) This filtering is done through a search parameter, as defined in the SponsoredContentFilterUtility.

We also make sure that if a user has a default search engine of that website, we don't add a sponsored tile of that type. Example; a user has Youtube as their default search engine, then we won't show a sponsored tile of Youtube.

Frecency tiles & Default suggested tiles

When first installing the application, we have default tiles called SuggestedSite that are set depending on the user's locale. The default suggested tiles are tiles that are bundled in the application. This ensures there's always tiles that are shown in the top sites, even if the users don't have any history-based tiles or pinned tiles.

Once a user start navigating, the rest of the tiles spaces will get populated with every visit to a new website. Each time a user visit a website, the visit gets recorded in RustPlaces. When we fetch the frecency data from RustPlaces, we use the following function func getTopFrecentSiteInfos(limit: Int, thresholdOption: FrecencyThresholdOption) -> Deferred<Maybe<[Site]>> which can be found here.

For more information on what this query returns, please see the Frecency Algorithm documentation

Tiles precedence flow chart

To help visualize the tiles precedence, here's a diagram.

Top sites tiles precedence

Clone this wiki locally