Analytics data from Search API usage

If you build your own search user interface using the AddSearch Search API, the following data is sent to AddSearch Analytics backend automatically:

  • Keywords used
  • Keywords not returning any results

To send information about the clicked search results, you can use a ready-made JavaScript function. First, add the following JavaScript to your search results page’s HTML template:

<script src="https://app.addsearch.com/www/script/searchapi/stats.js"></script>

After you have added the script element, you can call the following JavaScript function to feed search results clicks to the analytics server:

addsearchStats.click(
  sitekey, 
  keyword, 
  clickedDocId, 
  positionOfClickedDoc
);

Function’s parameters are

  • sitekey: Your public sitekey. Get it from your Dashboard’s Installation page
  • keyword: Keyword used to do the search
  • clickedDocId: ID of the search result being clicked. You get the ID from Search API’s response JSON, or calculate an MD5 hash of the document URL to create the ID by yourself
  • positionOfClickedDoc: Position of the result being clicked. The first result is 1, the second is 2 and so on. This is an optional parameter.

Self-learning algorithm

When the addsearchStats.click function is invoked, the data of results clicks is used to improve your search results by our self-learning algorithm.