HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Optimizely marks product recommendations sent to a site as _rendered_ on the website. Sometimes not all product recommendations are rendered on a Web page, so impression tracking ensures accurate reporting to correctly optimize site recommendations based on gathered data.

When products are returned through the **PeeriusCallbacks.smartRecs** function, two identifying values are included.

  • `refCode` – Client-side unique identifying code for each product that is passed to Optimizely through the product catalog feed.

  • `recommendation ID` – Value that uniquely identifies each individual product recommendation sent to the browser.


For the purposes of impression tracking, Optimizely solely uses recommendation IDs for product recommendation identification and thus only product recommendation IDs are mentioned in this topic. The inclusion of `refCodes` is for the identification of products on the client server-side only.

## Scenario 1: Any page

Optimizely sends widget A to a page, which contains 6 product recommendation IDs:

Out of the returned product recommendations in the widget you hand-pick only the following to display on the page: 10001, 10002 and 10005, and show them to the user.

## Scenario 2: Product Pages

Optimizely sends two widgets: A and B, with 6 recommendations in each:

You decide to show only the product recommendations from widget B with the following IDs: 20001, 20002, 20003, 20004, 20005 and 20006.

## Scenario 3: Basket and Interstitial pages

Optimizely sends three widgets: A, B and C, and the respective IDs for each widget are:

You decide to show some, but not all, product recommendations from Widget A, none from Widget B, and some recommendations from Widget C, as follows:

## Impression tracking stages

The implementation of impression tracking consists of two stages:

  • Stage 1. Instruct Optimizely to not create impressions for the product recommendations returned in the widgets.

  • Stage 2. Instruct Optimizely to mark specific product recommendations as shown on the site.

### Stage 1

To instruct Optimizely to stop counting impressions for product recommendations returned in the widgets, include the following JSON object in the `PeeriusCallbacks.track` variable:

The following example shows the above JSON object being used in the `PeeriusCallbacks` variable on a product page:

The next example shows the object used in the tracking variable on the basket page:

Add this object to the tracking variable for any page that receives product recommendations from Optimizely.

### Stage 2

After you instruct Optimizely to not mark the product recommendations as shown (that is, count the impressions), instruct Optimizely to create impressions for the product recommendations that are actually being displayed. You need the product recommendation IDs for the product recommendations from Optimizely that were displayed on the page. Using the example scenarios, you need the following IDs:

  • Scenario 1 – 10001, 10002 and 10005

  • Scenario 2 – 20001, 20002, 20003, 20004, 20005 and 20006

  • Scenario 3 – 10001, 10003, 10005, and 30002, 30004, 30006

To create the impressions for the displayed product recommendations, make a call to a sendAjax function for each of the widgets from which product recommendations were displayed, using the product recommendation IDs as parameters:

#### Scenario 1

#### Scenario 2

#### Scenario 3

For Scenario 3, you need to make two calls: one for each widget from which product recommendations were displayed. In this case, the calls are made to widget A and C.


The <clientname> element is unique for your site and will be provided by Optimizely.