Enabling Solr Analytics - SearchStax


This section describes how to add SearchStax® Analytics from Measured Search® to your existing website.

SearchStax analytics data is delivered to the dashboard through "apps." One creates an app in the SearchStax dashboard, and then configures the search-results web page to send data to the app. Each app is uniquely identified by an app_key.

To set up data capture, you need to have access to the source code for your search-results web page. It is expected that you have access to the website's HTML and JavaScript, and that you understand how your search results are parsed and displayed.

Create an App

You must create an Analytics "App" for your SearchStax deployment.

Screenshot

To create an Analytics App, please:

After the application is created, you will see a new app. SearchStax Analytics The app key is used in the results-page scripts to identify the app that will receive and analyze the data from that page.

Once the Solr application is deployed, you can open the app in the SearchStax dashboard to view data about search behavior.

To open an analytics app, click Analytics in the sidebar menu, and then click the blue arrow beside the appropriate app in the list. This exposes the dashboard for this specific app.

Delete an App

As the admin, you can delete an Analytics App directly from the SearchStax dashboard, but the button is hidden to prevent accidents. Note: There is no "undo." All data associated with this app will be permanently deleted.

To delete an Anaytics App, follow this path:

  1. Click Analytics in the left-side navigation bar.
  2. Click the blue arrow button to the right of the app you wish to delete.
  3. On the app's dashboard, click the blue Settings button in the upper left.
  4. This pops up a message box. Click the red Delete App button to delete the app.
  5. Type the name of the app into the delete-confirmation dialog box.

SearchStax Delete Analytics App

Connect Your Website to the App

Your search website communicates to the Analytics App through a javascript function on the web page.

Include Tracking Script

Add the following script before the ending body tag in your search-results page. You will have to replace the variables shown in UPPERCASE LETTERS with dynamic values available on the search results page. Note that only 'key' and 'query' attributes are required; everything else is optional. Just remove the lines that you don’t have dynamic values for. However, the more you can add, the better insights you’ll get from the Dashboard.

<script type="text/javascript"> 
var _msq = _msq || []; //declare object

(function() { var ms = document.createElement('script'); ms.type = 'text/javascript'; ms.src = 'https://static.searchstax.com/js/ms2.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ms, s); })(); 
</script>

Tracking Searches

When your web page submits a query, have it send this message to the Analytics App (identified by its APP_KEY):

_msq.push(['track', {
    key: 'REPLACE_WITH_APP_KEY',
    user: 'REPLACE_WITH_UID',
    session: 'REPLACE_WITH_SESSION_ID',
    query: 'REPLACE_WITH_QUERY',
    shownHits: 'REPLACE_WITH_SHOWN_HITS',
    totalHits: 'REPLACE_WITH_TOTAL_HITS',
    latency: 'REPLACE_WITH_LATENCY',
    pageNo: 'REPLACE_WITH_PAGE_NUMBER'
}]);

Below is an example of how the script looks like once you’ve substituted the UPPERCASE LETTERS with real values.

_msq.push(['track', { 
   key: "4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i", 
   user: "foobar123", 
   session: "XDJFNS355FGDFVVDFG", 
   query: "Steve Jobs – San Francisco, CA", 
   shownHits: 10, 
   totalHits: 1890, 
   latency: 150, 
   pageNo: 1 
}]);

Tracking Clicks

In order to start generating data around click-through, search quality & relevance, we need to track clicks on your site. In your search results page, replace the link to every search result with the following.

<a onClick="_msq.push(['trackClick', { 
    session: 'REPLACE_WITH_SESSION_ID',
    key: 'REPLACE_WITH_APP_KEY',
    query: 'REPLACE_WITH_QUERY',
    cDocId: 'REPLACE_WITH_DOCUMENT_ID',
    cDocTitle: 'REPLACE_WITH_DOCUMENT_TITLE'
    position: 'REPLACE_WITH_RESULT_POSITION',
    pageNo: 'REPLACE_WITH_PAGE_NUMBER',
    pageUrl: 'REPLACE_WITH_PAGE_URL',
    showHits: 'REPLACE_WITH_SHOWN_HITS',
    totalHits: 'REPLACE_WITH_TOTAL_HITS',
    lat: 'REPLACE_WITH_SEARCH_LATITUDE',
    lon: 'REPLACE_WITH_SEARCH_LONGITUDE',
    user_lat: 'REPLACE_WITH_USER_LATITUDE',
    user_lon: 'REPLACE_WITH_USER_LONGITUDE'        
}]);" href="REPLACE WITH LINK URL">REPLACE WITH LINK TITLE</a>

Below is an example of how the script looks like once you’ve substituted the UPPERCASE LETTERS with real values.

<a onClick="_msq.push(['trackClick', { 
   session: "XDJFNS355FGDFVVDFG", 
   key: '4Qp1Sv9MnALbAGbixW9ZaWrHxpbfwm6i', 
   query: 'Steve Jobs', 
   position: 4, 
   cDocId: 'http://mycompany.com/steve-jobs/', 
   cDocTitle: Steve Jobs', 
   pageNo: 1, 
   shownHits: 10, 
   totalHits: 1890
   lat: '33.916',
   lon: '-118.404',
   user_lat: '33.916',
   user_lon: '-118.404'        
 }]);" href="'http://mycompany.com/steve-jobs/">Steve Jobs</a>

Tracking Shopping Cart Additions

This is the format for logging shopping cart additions with the Analytics App:

<a onClick="_msq.push(['addToCart', { 
    category: 'REPLACE_WITH_PRODUCT_CATEGORY',
    id: 'REPLACE_WITH_ITEM_ID_OR_SKU',
    sku: 'REPLACE_WITH_ITEM_SKU',
    name: 'REPLACE_WITH_ITEM_NAME',
    key: 'REPLACE_WITH_APP_KEY',
    pageUrl: 'REPLACE_WITH_ITEM_URL',
    price: 'REPLACE_WITH_ITEM_PRICE',
    quantity: 'REPLACE_WITH_ITEM_QUANTITY',
    session: 'REPLACE_WITH_SESSION_ID',
    user: 'REPLACE_WITH_UID'   
}]);" href="'http://mycompany.com/cart/">Add to cart</a>

Tracking Transactions

When the user commits to a purchase, send this massage to the Analytics App:

_msq.push(['addTransaction', { 
    category: 'REPLACE_WITH_PRODUCT_CATEGORY',
    id: 'REPLACE_WITH_ITEM_ID_OR_SKU',
    sku: 'REPLACE_WITH_ITEM_SKU',
    name: 'REPLACE_WITH_ITEM_NAME',
    key: 'REPLACE_WITH_APP_KEY',
    pageUrl: 'REPLACE_WITH_ITEM_URL',
    price: 'REPLACE_WITH_ITEM_PRICE',
    quantity: 'REPLACE_WITH_ITEM_QUANTITY',
    session: 'REPLACE_WITH_SESSION_ID',
    user: 'REPLACE_WITH_UID'   
}]);

Tracking Feedback

SearchStax Analytics provides a mechanism for keeping track of user feedback about individual result items. On your search-results page you can approve/disapprove icons under each result. SearchStax will collect and keep track of clicks on these icons.

<a onClick="_msq.push(['trackFeedback', {
    key: 'REPLACE_WITH_APP_KEY',
    query: 'REPLACE_WITH_QUERY',
    cDocId: 'REPLACE_WITH_DOCUMENT_ID',
    cDocTitle: 'REPLACE_WITH_DOCUMENT_TITLE'
    position: 'REPLACE_WITH_RESULT_POSITION',
    pageNo: 'REPLACE_WITH_PAGE_NUMBER',
    pageUrl: 'REPLACE_WITH_PAGE_URL',
    showHits: 'REPLACE_WITH_SHOWN_HITS',
    totalHits: 'REPLACE_WITH_TOTAL_HITS',
    user: 'REPLACE_WITH_UID',
    session: 'REPLACE_WITH_SESSION_ID',
    'relevant': 'REPLACE_WITH_RELEVANCY',
}]);" href="REPLACE WITH LINK URL">REPLACE WITH LINK TITLE</a>

where relevant can be 1 or 0 (1 == relevant, 0 == not relevant).