This content is archived. See latest version here.

Last updated: Mar 19 2015

EPiServer Find Search Statistics provide additional tracking and statistics functionality. The EPiServer user guide describes the user interface.

Overview

Search Statistics provide an HTTP API for tracking searches made and getting statistical data about those searches. Based on aggregated statistics, they expose three functions that enhance the search experience: autocomplete, spelling suggestions, and related queries.

Although you can interact with the Search Statistics API using any programming language that makes HTTP requests, you typically use JavaScript to interact with the API. 

Tracking

To gather statistics for later analysis, use the Track() method in the search query. See also Tracking.

Note: Do not use StatisticsTrack to track statistics.

C#
SearchClient.Instance.Search<IContent>()
  .For("banana")
  .Track()
  .GetResult();

Autocomplete

Search Statistics support autocomplete suggestions by returning previous queries filtered on a prefix. A simple jQuery example is below. See also Autocomplete.

C#
<script type="text/javascript">
$.get('/find_v2/_autocomplete?prefix=c&size=3', function (data) {
    $.each(data.Hits, function(index, value)
    {
        $('#autocomplete').append("<p>"+"Autocomplete for 'c': <a href=/Search/?q=" + value.Query + ">" + value.Query + "</a></p>");
    }
    )}, "jsonp");
</script>
<div id="autocomplete"></div>

Autocomplete accepts the following parameters:

  • prefix (mandatory): the prefix to filter all returned query suggestions.
  • size (optional): the number of autocomplete suggestions to return.

Spellchecking

Based on what other users have searched for, Search Statistics can provide spellchecks, popular queries similar to the one passed to the spellchecker. A simple jQuery example is below. 

C#
<script type="text/javascript">
$.get('/find_v2/_spellcheck?query=camonix?size=1', function (data) {
    $.each(data.Hits, function(index, value)
    {
        $('#spellcheck').append("<p>"+"Spellcheck for 'camonix': <a href=/Search/?q=" + value.Suggestion + ">" + value.Suggestion + "</a></p>");
    }
    )}, "jsonp");
</script>
<div id="spellcheck"></div>

The spellchecker accepts these parameters:

  • query (mandatory): the query to return spellchecks for.
  • size (optional): the number of spellchecks to return.

Related queries

Sometimes, it is valuable to discover relationships, for example people who search for a also search for b. Search Statistics calls this related queries. They can be requested using jQuery, as shown below. See also Related queries.

C#
<script type="text/javascript">
$.get('/find_v2/_didyoumean?query=chamoni&size=1', function (data) {
    
$.each(data.Hits, function(index, value)
    
{
        $('#didyoumean').append("<p>"+"Didyoumean for 'chamonix': <a href=/Search/?q=" + value.Suggestion + ">" + value.Suggestion + "</a></p>");
    
}
    
)}, "jsonp");
</script>
<div id="didyoumean"></div>

Related queries accept these parameters:

  • query (mandatory): the query for which to return related queries.
  • size (optional): the number of related queries to return.

Comments

This documentation needs to be updated. .Track() has been renamed .StatisticsTrack() http://world.episerver.com/documentation/Items/Upgrading/EPiServer-Find/9/breaking-changes/

Thanks for pointing this out, has been updated now.

You need to update the other page as well or am i wrong? I still says Track() on the subpage /tracking.

Done. Once again, thanks for noticing.

Hi,

One of EPiServer's Find developers mentioned that we should revert to Track() method for now. The problem is StatisticsTrack() doesn’t add all default tags (like site ID) as Track does. As a result, features like autocomplete and autocorrect stop suggesting phrases based on previous statistics, if the statistic is not marked with site ID tag.

I see both Track() and StatisticsTrack() methods, are they both doing the same thing? 

Find administrator can see search/click statistics for selected site and language in Find UI.

The difference between these two methods is that EPiServer.Find.Framework.Statistics.Track() extension adds default tags (site and language ids) automatically.

EPiServer.Find.Statistics.StatisticsTrack() does NOT add default tags when tracking, so developer has to provide site and language tags in his/her code.