1. Help Center
  2. Search Recommendation

Add click tracking for Search Personalization

In order to be able to measure the lift of the Raptor PersonalSearchBoost algorithm, we need to know when a user clicks on a search result, and in particular, when a user clicks a search result which has been up-ranked by Raptor.


Step 1: Decorate the search result anchor tags with "isBoosted" information

The output from the search advisor module contains information about the rank of the items, compared to the original result. All search result items returned from Raptor contains a flag, "IsBoosted=true/false", describing if an item has been up-ranked by Raptor.

rerank

So now, when you render the search result, you can decorate the anchor tags with this information.

Example:

boostedlinks.PNG

Step 2: Track when user clicks the search result links

This step can vary a lot, depending on your implementation. The code below is only shown to illustrate the example. 

The main goal of the code below is to send a tracking event to Raptor, containing the information if the clicked product were boosted or not boosted by Raptor.

This is achieved by sending either a "SearchBoostedClick" or "SearchNonBoostedClick" tracking event to Raptor.

Example (using jquery): 

$("#raptorSearchResult a").click(

function () {

//Get the data attribute with the boost info
var isBoosted= $(this).attr("data-raptorboosted");

var eventType= isBoosted=="true"? "SearchBoostedClick":"SearchNonBoostedClick";


//Replace [ProductId] with actual productid and [RedirectUrl]
//with the url of the clicked product
//The "methodName" should match the name of the Raptor module
//that is used for obtaining the search rerank result
raptor.trackClickEvent({ methodName: 'PersonalSearchBoost' },
[eventType,
"[ProductId]"],
"[RedirectUrl]");

});

 

🔍 Note:  The array of arguments must fit the placement of the parameters in initialize method. So, if productId is number 5 – then the array must contain of 5 elements with the productId as number 5. 

Like this:

raptor.trackClickEvent({ methodName: 'PersonalSearchBoost' }, 
[eventType,,,,"[ProductId]"], "[RedirectUrl]");

 

You can find the order of parameters in the Raptor Control Panel