Skip to main content
RichRelevance

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.setApiKey('abcd5432e1');
  R3_COMMON.setBaseUrl(window.location.protocol+'//integration.richrelevance.com/rrserver/');
  R3_COMMON.setClickthruServer(window.location.protocol+"//"+window.location.host);
  R3_COMMON.setSessionId('6B4D397B');
  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
  R3_COMMON.addPlacementType('home_page');

  // Replace placement_name with the placement name you set up in Dashboard.
  // Call multiple times to display more than one placement.
  R3_COMMON.addPlacementType('home_page.placement_name');
  
  // This sets the page brand which allows strategies that need page brand to run (such as Brand Top Sellers)
  R3_COMMON.setPageBrand('Nike');
  
  // 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.
  R3_COMMON.addFilterBrand('Puma');
  
  // 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.
  R3_COMMON.setFilterBrandsIncludeMatchingElements('true');
  
  var R3_HOME = new r3_home();
  rr_flush_onload();
  r3();
</script> 

APIs

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

  • Was this article helpful?