Skip to main content
RichRelevance

Integration: Category Context

Category hints providing additional category context that may allow additional strategies. Category hints can be added to any page type.

Setting the category context can be useful on pages that may have an ambiguous category, such as item pages for items that live in multiple categories. If you don’t set the category context, some strategies will derive category information from the product ID. In this situation, the context can be set to match the user’s bread crumb trail.

Category hints can be added to any page type. Several category hints can be added on a single page. Each category hint added qualifies the page for merchandising rules that are associated to the category.

JavaScript Integration

How To Make This Code Work For You

  1. Create the integration code on each of the pages on your site, following the HTML integration and JSON integration guides.
  2. Add this function to your integration code:
Function Requirement
R3_COMMON.addCategoryHintId(‘CATEGORY_ID’); Replace CATEGORY_ID with a unique identifier for the category. CalladdCategoryHintId() as many times as you need to pass the category IDs that apply to the page.

Sample Code

Call addCategoryHintId() in the Primary Code Block.

JSON

<!-- Place 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 exists, set it; if not, set it as session ID
  
  // here's an example requesting recommendations for 1 page area
  R3_COMMON.addPlacementType('home_page.rr1');
 
  var R3_HOME = new r3_home();
 
  R3_COMMON.addCategoryHintId(‘Electronics’);
 
  rr_flush_onload();
  
  r3();
</script>

APIs

In recsForPlacements, use the chi parameter to supply category hint IDs.

  • Was this article helpful?