Skip to main content

HTML Integration: Purchase Complete 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 Purchase Complete Page (JSON)

The purchase complete page is the page displayed to customers immediately after they successfully purchased their items.

This is a required page type. Even if no placements appear on this page, the integration logic must be present.

How To Make This Code Work For You

Function Requirement
R3_COMMON.setApiKey('MY_API_KEY'); Replace MY_API_KEY with your site’s API key, a unique identifier for your account.

Set RRSERVER_URL to one of these 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.

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 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_PURCHASED.setOrderNumber('ORDER_ID'); Replace ORDER_ID with the order ID, a unique identifier for the order.
R3_PURCHASED.addItemIdPriceQuantity('ITEM_ID', 'PRICE', 'QTY', 'SKU'); Use this function once for every item purchased.
Replace ITEM_ID with the item ID, a unique identifier for the item.Replace PRICE with the price of a single item in decimal format, ex. 19.99. Replace QTY with the quantity for this product.Replace SKU with the specific SKU the user has purchased. If there is no SKU ID, this can be left empty.​

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

Primary Code Block

<!-- Place this code inside the <body> element as close to the top as possible -->
<script src="//"></script>
<script charset="utf-8" type="text/javascript">
  var R3_COMMON = new r3_common();
  R3_COMMON.setUserId('1');  // if no user ID is available, please leave this blank
  // here's an example requesting recommendations for 3 page areas
  var R3_PURCHASED = new r3_purchased();
  // example purchased product:
  // product ID = 21666189, price = $499.99,
  // quantity = 1, SKU = 9876A
  R3_PURCHASED.addItemIdPriceQuantity('21666189', '499.99', '1', '9876A'); // iterate over this line for each item purchased

Placement-marker Code Blocks

<script charset="utf-8" type="text/javascript">
<!-- Page contents -->
<script charset="utf-8" type="text/javascript">
<!-- Page contents -->
<script charset="utf-8" type="text/javascript">

Flush Code Block

<script charset="utf-8" type="text/javascript">


  • The values in addPlacementType() should match the values in each r3_placement() call.
  • This page is often secure (served via HTTPS). If not using window.location.protocol, provide “https” in R3_COMMON.setBaseUrl():
  • The PRICE passed in R3_PURCHASED.addItemIdPriceQuantity() is the single unit price. Algonomy multiplies this by the quantity to determine line item order value.
  • Was this article helpful?