How To

Add Filters To URL

2min



There are scenarios when it is useful for the user selected filters and/or merchant preset filters to be captured as part of the SRLP or Category URL.

For Example:

  • Allow for consistent tracking of selected facets.
  • Reusable 'landing page' links

To accomplish this we will add in a custom override module named addFiltersToURL that will:

  1. Intercept the outgoing query
  2. Analyze the existing URL string
  3. Update the localstorage of selected facets
  4. Apply the necessary filters to the outgoing query
  5. Update the existing URL string

See : Modify Request Overview and Modify Response Overview for details on Klevu JS overriding



Template JS Override

Add the supporting module, addFiltersToURL and apply its use to the page overrides.

Note : The example is set for both Search (landing) and Category (catnav) scopes.



Full Example

JavaScript
Text