Skip to main content

Preselect size from Recommendation Engine

In this section you will learn how to preselect the matching framesize on the new product page right away when a user clicks on an alternative bike.

info

When the Recommendation Engine shows alternative bikes and the customer clicks on one of these bikes this will open in a new tab/window based on the URL given in the product feed. Often times this URL does not include information about the selected size, instead all sizes of one model have the same URL. As the product will be opened in a new tab we can't use a callback function to select the recommended size as in the Online Sizing.

Instead you can add additional URL parameters to the links that can be read on page load and then create a custom function that uses this information to preselect the recommended size for the customer.

Add additional URL parameters

Login to Smartfit Analytics. Follow the instructions here to add URL parameters to the product links.

Once parameters have been mapped links to new tabs from your Recommendation Engine will include these parameters. This might look the following:

https://wwww.yourbikeshop.com/bikes/mtb/scott-scale-980&variationId=1063202#gtin=7615523114986

Create custom functions

Read URL parameters

There are multiple ways to read the URL parameters. One way is to use a javascript function for searchParams as described here or hash as described here to get values from the URL.

Example:

URL: https://wwww.yourbikeshop.com/bikes/mtb/scott-scale-980&variationId=1063202#gtin=7615523114986

The following code saves the value of the gtin and variationId in the URL parameter, in this case 7615523114986 and 1063202.

const url = new URL(document.URL);
const gtin = url.hash.substring(1);
const variationId = url.searchParams.get("variationId");

Select bike

With the data from the URL parameters you now need to select the recommended size. Therefore you may use the same function that is used in the confirm size callback.