This content is archived. See latest version here

Last updated: Sep 21 2015


Tracking involves storing statistical data about search queries submitted by site visitors, and search results that they clicked. Tracking provides content administrators deeper insight into the efficiency of the search and identifies areas of improvement and optimization to better serve vistors with relevant content.

Automatic tracking

The recommended way to enable tracking is to call Track() on the search query.



Track() ensures that the required tracking information is added to the URLs of the search hits. JavaScript is automatically injected in the footer of the page that handles the tracking of the hits.

When using Unified Search, Track() enables tracking of both the query and hits. When using Track() on a non-Unified Search, it only enables tracking of the query. Use custom tracking (explained below) to track hits with a non-Unified Search.

Note: The client side scripts used for tracking depends on having set the EPiServer.Framework.Web.RenderingTags in the page templates:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<%@ Import Namespace="EPiServer.Framework.Web" %>
<%@ Import Namespace="EPiServer.Framework.Web.Mvc.Html" %>
<head runat="server">
<%= Html.RequiredClientResources(RenderingTags.Header) %>
<%= Html.RequiredClientResources(RenderingTags.Footer)%>

Custom tracking

To implement a custom tracking mechanism, use the StatisticsClient, which offers two methods: TrackQuery() and TrackHit().

Access the StatisticsClient as follows:


Use TrackQuery(), as the name suggests, to track the user query. It returns a TrackQueryResult with the TrackId.

Use the TrackId returned from TrackQuery() to track hits through the existing Javascript. You typically implement this scenario when using a non-Unified Search, and must manually enable hit tracking. This requires you to supply required tracking information as querystring parameters in the hit URL.

Tracking querystring parameters

  • _t_id: TrackId, returned from client.Statistics().TrackQuery(...)
  • _t_q: The search query string
  • _t_tags: Tags for categorization of the collected data. Normally contains site and language tags.
  • _t_ip: Client IP address
  • The expected format for a hit id (hitId argument to StatisticsClient.TrackHit) is the type name used in the index and the ID of the document in the index separated by a slash. Example: "EPiServer_Templates_Alloy_Models_Pages_ProductPage/_cb1b190b-ec66-4426-83fb24546e24136c_en"

    When SearchHit<T> objects (from GetResult) are available, combine the SearchHit.Type and SearchHit.Id properties for the appropriate search hit.

    If you instead need to construct this value based on only the object that was indexed, use this syntax: client.Conventions.TypeNameConvention.GetTypeName(myObj.GetType()) + "/" + client.Conventions.IdConvention.GetId(myObj)

  • _t_hit.pos: The ordinal position the hit was in.

Use TrackHit() to track a search hit. In other words, it is a way to achieve click tracking. TrackHit() takes a query and hit ID as parameters. The format of the hit id parameter is the same as described for the querystring parameter above.

Do you have feedback on this documentation? Send an email to For development-related questions and discussions, refer to our Forums on