Skip to main content

Integration: 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 Algonomy 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.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.
  var R3_HOME = new r3_home();
  R3_COMMON.addSegment('MN236', 'Corporate Account Holders');


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

  • Was this article helpful?