Skip to main content
RichRelevance

Segments

To use a user’s segment(s) in recommendations, important information must be passed on every page for the segmented user.­­

Important: Before you add segment information to your instrumentation, please speak with your RichRelevance team to have segments enabled for your account.

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 JSON integration guide.
  2. Add this function to your integration code:
Function Requirement
R3_COMMON.addSegment('SEGMENT ID', 'SEGMENT NAME'); Replace SEGMENT_ID with the unique identifier for the current user’s segment. Replace SEGMENT_NAME with a human-friendly name for the current user’s segment.

Sample Integration Code

Call addSegment() in the 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');
  
  var R3_HOME = new r3_home();
  R3_COMMON.addSegment('MN236', 'Corporate Account Holders');
  rr_flush_onload();
  r3();
</script> 

APIs

Use thesgsparameter to send the shopper’s segment every time you call recsForPlacements.