Skip to main content

Brand Filtering

If brand information is passed in the feed, we can filter recommendations by brand. Filters can be applied so that recommendations only include a given brand or brands, or alternatively, so that they exclude a given brand or brands.

Care must be taken when adding filters. Because recommendations are returned from run-time representations of your catalog and not the entire catalog, over-filtering can prevent any recommendations from appearing. If you plan to add more than one type of filter on a page, please let your Algonomy team know so they can help guide you.

How To Make This Code Work For You

Add the following lines of code to your page tags, adding the required information to them:

Function Requirement
R3_COMMON.setPageBrand('Brand Name'); Replace Brand Name with the name of the primary brand on the page. You can only call setPageBrand once, but if you want to add more brands you can do so withaddFilterBrand().
R3_COMMON.addFilterBrand('Brand Name'); Replace Brand Namewith the name of a brand you want to include or exclude from the recommendations.
R3_COMMON.setFilterBrandsIncludeMatchingElements('True False'); Select either True or False. Add ‘true’ if you want recommendations to include only the brands that you’ve set withaddFilterBrand(). If set to ‘false’ (the default), recommendations exclude the specified brands. If set to ‘true’, the brand filter excludes all products except the specified brands.

Sample Code

Call setPageBrand() and addFilterBrand() in the Primary Code Block.

Primary Code Block

<!-- Place this code inside the <body> element as close to the top as possible -->
<script charset="utf-8" type="text/javascript">
  var R3_COMMON = new r3_common();
  R3_COMMON.setUserId('10987');  // if no user ID is available, please leave this blank

  // Use this code if you are not requesting placement(s) for personalization

  // Replace placement_name with the placement name you set up in Dashboard.
  // Call multiple times to display more than one placement.
  // This sets the page brand which allows strategies that need page brand to run (such as Brand Top Sellers)
  // Builds pipe delimited list of brand value(s) to use in filtering recs for all placements and
  // strategies utilized on the page. Should be called multiple times to pass in more than one brand.
  // Instructs the system whether to include or exclude the elements that match the brand filter.
  // The system will default to excluding the matching elements if this method is not called.
  var R3_HOME = new r3_home();


Use the filbr and includeBrandFilteredProducts parameters to filter by brand when you call recsForPlacements.

  • Was this article helpful?