- DotNET Client API
- Client class
- Deleting documents
- File attachments
- Getting documents
- Inheritance and interfaces
- References and configuration
- Customizing serialization
- Auto Boosting
- Best Bets
- Boosting with filters
- Boosting with weights
- External content
- Free text search
- Geo Search
- Including documents matching a filter
- More Like/Related
- Multiple searches in one request
- Pagination (Skip and Take)
- Related Queries
- Searching over multiple types
- Unified search
- EPiServer 7/7.5 CMS
- EPiServer 7.5+
- EPiServer CMS 6 R2
- Shell module
- REST API
- Search statistics
This content is archived. See latest version here
Last updated: Dec 15 2014
Tracking is the process of storing statistical data about queries that visitors to the site have searched for, as well as the hits that they have clicked on.
The purpose of tracking is to help the content administrator to gain a deeper insight into the efficiency of the search functionality and to identify areas of improvement and optimization to better serve vistors with relevant content.
The recommended and standard way to enable tracking on your site is to call Track() on the search query.
When using Unified Search, Track() enables tracking of both the query and the hits. When using Track() on a non-Unified Search, it only enables tracking of the query. Refer to custom tracking below for information on how to achieve hit tracking for 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" %>
<%= Html.RequiredClientResources(RenderingTags.Header) %>
You can utilise the StatisticsClient to implement a custom tracking mechanism. The StatisticsClient offers two methods: TrackQuery() and TrackHit().
Access the StatisticsClient as follows:
TrackQuery(), as the name suggests, is used to track the user query. It returns a TrackQueryResult with the TrackId.
You would typically implement this scenario when you are using a non-Unified Search, and have to manually enable tracking of hits.
This requires you to supply the required tracking information as querystring parameters in the hit URL.
The complete list of tracking querystring parameters is as follows:
- _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
- _t_hit.id: 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 you have the SearchHit<T> objects (from GetResult) available, you can simply 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, it could be done as follows: client.Conventions.TypeNameConvention.GetTypeName(myObj.GetType()) + "/" + client.Conventions.IdConvention.GetId(myObj)
- _t_hit.pos: The ordinal position the hit was in.
TrackHit() is used to track a search hit. Stated in other words, it is a way to achieve click tracking. It takes a query and hit ID as parameters. The format of the hit id parameter is the same as described for the _t_hit.id querystring parameter above.