How to sort products in your advice based on a given answer
Sometimes you want the user to have the ability to choose what's more important to them. For example, when you want to know if the user prefers quality or price. You can do this by using the "sorting" feature when setting up your matching rules.
1. Go to "Matching" in the left navigation.
2. Go to the "Data matching" tab.
3. Select the question you want to edit on the left.
4. Open the answer you want to apply the sorting for.
5. Click the "add" button and choose "Add sorting".
6. Choose which property you want to sort on and in which direction.
Please note: sorting will be applied after the scoring. This means the sorting will only be applied to products with the same score. To see which scores products have in your advice, please check out the "Match testing" section on the matching documentation page.
Sorting by distance
When you have a property of the "Location" type, you can also sort based on distance.
Example: dealer locator
1. Add a property to your feed and set the type to "Location". This property will need to be in the lat,lng format. For example: 52.377892,4.899730.
2. Create a flow where the user can input it's own location.
3. Make sure you have "Variables" enabled (Settings -> Configure -> Enable variables) and add a variable "location" to the "Text input" step where we'll store the user input.
4. Next, in the operation step, we'll use the "location" variable in a Google Maps API call to get the user location GPS (latitude/longitude) data.
5. In the operation step, go to the variables tab and add a "lat_lng" variable where we store the API result in the correct format (lat,lng).
6. Now that we have the user's lat/lng data, we can go to "Feed -> Matching" and add a "Sort by" rule to the operation answer where we'll sort on distance between the feed location and user's location.
7. [optional] When you have "Calculated properties" enabled (Settings -> Feed -> Enable calculated properties), you can use the "internal.distance" variable to show the distance in the results.
Awesome! You have now created a dealer locator where the user enters a zip code or location on which the results are sorted by distance to the user.
Documentation