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

Impression tracking

Describes how to configure impression tracking for your web page.

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.

📘

Note

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:

Widget A: [ 10001, 10002, 10003, 10004, 10005, 10006 ]

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:

Widget A: [ 10001, 10002, 10003, 10004, 10005, 10006 ]
Widget B: [ 20001, 20002, 20003, 20004, 20005, 20006 ]

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:

Widget A: [ 10001, 10002, 10003, 10004, 10005, 10006 ]
Widget B: [ 20001, 20002, 20003, 20004, 20005, 20006 ]
Widget C: [ 30001, 30002, 30003, 30004, 30005, 30006 ]

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:

Widget A: [ 10001, 10003, 10005 ]
Widget B: [ ]
Widget C: [ 30002, 30004, 30006 ]

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:

"smartRecs": { 
               "markRecsAsShown": false
             }

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

var PeeriusCallbacks = {
                         track = {
                           "product"   : {
                             "refCode" : "<refCode1>"
                           },
                           "type"      : "product",
                           "lang"      : "de",
                           "channel"   : "web",
                           "smartRecs" : {
                             "showAttributes"  : ["*"],
                             "markRecsAsShown" : false
                           }
                         }
};

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

var PeeriusCallbacks = {
                         "track": {
                           "type"      : "basket",
                           "lang"      : "en-gb",
                           "channel"   : "web",
                           "smartRecs" : {
                             "showAttributes": ["*"],
                             "markRecsAsShown": false
                           },
                           "basket"    : {
                             "items"   : [
                               {
                                 "refCode" : "<refcode1>",
                                 "qty"     : "2",
                                 "price"   : "100.00"
                               },
                               {
                                 "refCode" : "<refcode2>",
                                 "qty"     : "1",
                                 "price"   : "10.00"
                               }
                             ],
                             "currency" : "GBP"
                           }
                         }
}

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

Peerius.sendAjax("<clientname>/rec/shown.pagex?ids=10001,10002,10005")

Scenario 2

Peerius.sendAjax("<clientname>/rec/shown.pagex?ids=20001,20002,20003,20004,20005,20006")

Scenario 3

Peerius.sendAjax("<clientname>/rec/shown.pagex?ids=10001,10003,10005") Peerius.sendAjax("<clientname>/rec/shown.pagex?ids=30002,30004,30006")

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.

📘

Note

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