HTML Integration: Category Page (Legacy)
NOTE This section refers to a legacy feature which is only available to existing customers. New and existing customers looking to add personalization should refer to Category Page (JSON).
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
If you copy the sample integration code below, make these changes:
Function | Requirement |
---|---|
R3_COMMON.setApiKey('MY_API_KEY'); |
Replace MY_API_KEY with your site’s API key, a unique identifier for your account. |
R3_COMMON.setBaseUrl(RRSERVER_URL); |
Set 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 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. Call R3_COMMON.addItemId() up to 15 times to pass the product IDs of the first 15 products on the page. |
R3_COMMON.setClickthruServer(window.location.protocol+'//'+window.location.host) |
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 m.retailer.com or UAT.retailer.com, we can automatically redirect to the correct domain. |
Sample Integration Code
Primary Code Block
<!-- Place this code inside the <body> element as close to the top as possible --> < script src = "//media.richrelevance.com/rrserver/js/1.2/p13n.js" ></ script > < 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('1'); // if no user ID is available, please leave this blank // here's an example requesting recommendations for 3 page areas R3_COMMON.addPlacementType('category_page.rr1'); R3_COMMON.addPlacementType('category_page.rr2'); R3_COMMON.addPlacementType('category_page.rr3'); var R3_CATEGORY = new r3_category(); R3_CATEGORY.setId('Electronics_BTS'); // category ID must match a category id as passed in catalog feed R3_CATEGORY.setName('Back-to-School Electronics'); // category name as it should be displayed to customers, overrides the value provided in the catalog feed for this category ID // provide product IDs for items displayed on the category page (LIMIT of 15). Use the following line of code for each product ID. R3_COMMON.addItemId('21666189'); // if item has parent ID, pass the parent ID r3(); </ script > |
Placement-marker Code Blocks
< script charset = "utf-8" type = "text/javascript" > r3_placement('category_page.rr1'); </ script > <!-- Page contents --> < script charset = "utf-8" type = "text/javascript" > r3_placement('category_page.rr2'); </ script > <!-- Page contents --> < script charset = "utf-8" type = "text/javascript" > r3_placement('category_page.rr3'); </ script > |
Flush Code Block
< script charset = "utf-8" type = "text/javascript" > rr_flush_onload();</ script > |
Notes
- The values in
addPlacementType()
should match the values in eachr3_placement()
call.