Skip to main content

JSON Integration: Category Page

A category page displays either a subset of related products or a group of sub-categories that help the customer navigate deeper into the site. It may be a department page, genre page, vertical page etc., depending on your nomenclature.

How To Make This Code Work For You

Follow the sample integration code below, making these changes:

Function Requirement
R3_COMMON.setApiKey('API Key'); Replace API Key with your site’s API key, a unique identifier for your account.
R3_COMMON.setBaseUrl(window.location.protocol+'//RR Server'); Set RR Server URL to one of the following values:

For initial development:
For production:
R3_COMMON.setSessionId('User Session ID'); Replace User Session ID with the session ID for the current user and session. The session ID is a crucial variable that allows Algonomy to track shopper behavior when they visit your site so recommendations can be generated. This parameter should remain the same from start to finish for a user’s shopping session.
R3_COMMON.setUserId('User ID'); Replace User ID with the user ID, a unique string to identify each user. All user behavior will be stored using this key. It is case-sensitive and should be the same user ID sent to Algonomy in other applications. User IDs are often connected to email addresses, and can be directly linked to the login credentials a consumer uses to log into and buy products from the e-commerce site. To avoid sending personally identifiable information to Algonomy, you can use a hash of your site’s user ID (if, for example, your site uses email addresses as user IDs, then you should not send that information directly to Algonomy).

Note: If the User ID is unknown, leave it blank.
R3_CATEGORY.setId('Category ID'); Replace Category ID with a unique identifier for the category.
R3_CATEGORY.setName('Category Name'); Optional: Replace Category Name with a user-friendly name for the category. This name is displayed to shoppers. If you don’t set a category name here, shoppers see the category name value provided in the feed.
R3_COMMON.addItemId('Item ID'); Replace Item ID with an item ID (product ID) for a product shown on the category page. CallR3_COMMON.addItemId() up to 15 times to pass the product IDs of the first 15 products on the page.
R3_COMMON.addPlacementType('category_page.Placement Name'); Replace Placement Name with the Placement ID. You can find your Placement IDs in the Dashboard under the Placements section. If you do not display personalization on this page, call R3_COMMON.addPlacementType('category_page');instead.

No changes are required.

This code enables the client to send the domain for click-through URL through the p13n_generated.js call if relative URLs are supplied in the feed. For example, if the domain calling our code is or, we can automatically redirect to the correct domain.

Sample Integration Code

Algonomy JavaScript Library

<!-- Primary function library placed before the callback and Primary Code Block. -->
<script src="//"></script>

Callback Function

This function will consume the JSON response object. Place anywhere in between your <script> tag that loads p13n.js and the r3() function call.

<script charset="utf-8" type="text/javascript">
  RR.jsonCallback = function(){
    // Place your rendering logic here. Actual code varies depending on your website implementation.

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_CATEGORY = new r3_category();
  // Category ID must match a category id as passed in catalog feed

  // If you want, you can specify the category name as it should be displayed to customers.
  // This is optional. If you pass a value, it will override the one provided in the Product Feed
  // for this Category ID.
  R3_CATEGORY.setName('Back-to-School Electronics'); 
  // Provide up to 15 Product IDs the for items displayed on this page.
  // Call this method once per Product ID.
  // If this item has a Parent ID, you can pass it as a second argument.



  • Placements requested via addPlacementType() should always be displayed on the page.
  • Was this article helpful?