Skip to main content
RichRelevance

Generic 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 Generic Page (JSON)

If you have a page that doesn’t fit any of the other page types, you might consider using the generic page.

How To Make This Code Work For You

Follow the sample integration code below, making 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 RRSERVER_URL to one of these values.

For initial development:

window.location.protocol+'//integration.richrelevance.com/rrserver/'

For production:

window.location.protocol+'//recs.richrelevance.com/rrserver/'

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 RichRelevance 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 UserId sent to {rr} 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 RichRelevance, 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 RichRelevance).

Note: if the USER_ID is unknown, leave it blank.

R3_COMMON.addItemId('ITEM_ID'); Optional: Replace ITEM_ID with the item ID, a unique identifier for an item shown on the page. Used as a seed for item-based strategies. If no category or brand information is set, the category and brand may also be derived from the item ID.
You can add more than one item ID with multiple calls to R3_COMMON.addItemId.
R3_COMMON.setPageBrand('BRAND') Optional: Replace BRAND with the primary brand to identify with the page. Used as a seed for brand-based strategies.
You can add additional brands withR3_COMMON.addFilterBrand. See Supplement: Brand Filtering for more on working with multiple brands.
Brands are case sensitive and must exactly match a brand name listed in your catalog.
R3_COMMON.addFilterBrand('BRAND');
R3_COMMON.setFilterBrandsIncludeMatchingElements('true');
Optional: If the page is identified with more than one brand, replace BRAND with the brand names of the non-primary brands. Call R3_COMMON.addFilterBrand once for each additional brand. SetR3_COMMON.setFilterBrandsIncludeMatchingElements to true.
Brands are case sensitive and must exactly match a brand name listed in your catalog.
R3_COMMON.addCategoryHintId('CATEGORY_ID'); Optional: Replace CATEGORY_ID with the category ID for primary category associated with the page. Used as a seed for category-based strategies. See Supplement: Providing Category Context.
Category names are case sensitive and must exactly match a category name in your catalog.
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('generic_page.rr1');
  R3_COMMON.addPlacementType('generic_page.rr2');
  R3_COMMON.addPlacementType('generic_page.rr3');
 
<!-- OPTIONAL DATA FOR STRATEGIES-->
 
<!-- ENABLES CLICKCP / VIEWCP BASED STRATEGIES. ITEM ID IS THEN USED TO LOOKUP CATEGORY AND BRAND
TO ENABLE THOSE SRTATEGIES.
DOES NOT COOKIE ITEM ID FROM GENERIC PAGE VIEW. -->
R3_COMMON.addItemId('32659821');
R3_COMMON.addItemId('14931797');      //CAN PASS MULTIPLE IDS AS SEEDS
 
//R3_COMMON.setPageBrand('Sony');     //ENABLES BRAND STRATEGIES (Case Sensitive)
 
<!-- ENABLES YOU TO PASS MULTIPLE BRAND FILTERS, WHICH EXCLUDES THESE ITEMS BY DEFAULT
USAGE OF setFilterBrandsIncludeMatchingElements('true') INCLUDES PRODUCTS WITH MATCHING BRAND(S).
(Case Sensitive) -->
//R3_COMMON.addFilterBrand('Vizio');
//R3_COMMON.addFilterBrand('Dell');  
 
<!-- IF TRUE, INCLUDES BRANDS. IF FALSE OR OMITTED, EXCLUDES MATCHING BRANDS. -->
//R3_COMMON.setFilterBrandsIncludeMatchingElements('true');
 
<!-- ENABLES CATEGORY SEEDED STRATEGIES OFF MATCHING CATEGORY ID (Case Sensitive) -->
//R3_COMMON.addCategoryHintId('Baby');
 
  var R3_GENERIC = new r3_generic();
 
  r3();
 
</script>

Placement-marker Code Blocks

<script charset="utf-8" type="text/javascript">
  r3_placement('generic_page.rr1');
</script>
 
<!-- Page contents -->
 
<script charset="utf-8" type="text/javascript">
  r3_placement('generic_page.rr2');
</script>
 
<!-- Page contents -->
 
<script charset="utf-8" type="text/javascript">
  r3_placement('generic_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 each r3_placement() call.