Check out the guide
http://dmytroduk.com/techblog/statistics-tracking-in-episerver-find
and see if you missed a step. Strange that you get parts of it working...
Thanks for the reply!
I'm doing a multi-search (the same query but with separate resultsets depending on additional parameters) and therefore track the query manually:
var tags = ServiceLocator.Current.GetInstance<IStatisticTagsHelper>().GetTags().ToList(); _trackingId = new TrackContext().Id; SearchClient.Instance.Statistics().TrackQuery(_trackingQuery, x => { x.Id = _trackingId; x.Tags = tags; x.Query.Hits = totalNumberOfHits; });
..and apply the querystring values also manually:
searchHit.Url = searchHit.Url.AppendQueryStringParameter("_t_id", HttpUtility.UrlEncode(_trackingId)); searchHit.Url = searchHit.Url.AppendQueryStringParameter("_t_q", HttpUtility.UrlEncode(_trackingQuery)); searchHit.Url = searchHit.Url.AppendQueryStringParameter("_t_tags", HttpUtility.UrlEncode(_trackingTags)); searchHit.Url = searchHit.Url.AppendQueryStringParameter("_t_ip", _trackingIP); searchHit.Url = searchHit.Url.AppendQueryStringParameter("_t_hit.id", string.Format("{0}/{1}", hit.Type, hit.Id)); searchHit.Url = searchHit.Url.AppendQueryStringParameter("_t_hit.pos", position.ToString());
I've compared the manually generated querystring with one automatically generated from a tracked unified query and they seem to match.
Comparing with the three screenshots from the site, I see clicks like for the search phrase "plan", but in my case "plan" is also displayed under "Searches without relevant hits" with 0% click-rate.
Ok and you've of course checked that your parameter with totalNumberOfHits isn't 0 I guess?
Yes, the number of hits are the correct sum of the counts from the multiple queries.
Yes, the request is triggered when the clicked page has loaded and looks like:
http://site.web.local/find_v2/_track?id=TQqtK-h05Bg9VjFh9Cl-Dw%3d%3d&q=test&tags=language%3asv%2csiteid%3a3b0ae0c6-50ab-4ff7-9b97-00f11dc40275&ip=127.0.0.1&hit.id=X_Web_Models_Pages_XmlDocumentPage/_ff788810-4eae-4fea-910a-a27051d698b1_sv&hit.pos=1
The response looks like:
{"status":"ok","track_id":"TQqtK-h05Bg9VjFh9Cl-Dw==","track_uuid":"7udJbiDUT9W04_tR8UMFNQ"}
The strange thing is that I see the tracked query in the statistics view as well as the tracked click. But under "Searches without relevant hits" it shows a click-rate of 0%. This occurs in both dev and test environment with different indexes.
Yes, there's no Track() in any of the queries. It's all done by a single TrackQuery(..) call. The search count in the statistics UI also seems to indicate this.
Btw, thank you very much for the http://geta.no/blogg/building-an-advanced-search-page-using-episerver-find/ post! Helped me a lot as I was facing the same requirements :)
I would check if _trackingId is correct, so you track clicks for corresponding searches.
Some quotes from documentation:
Use TrackQuery() 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.
Could you try to use TrackId from TrackQueryResult returned by SearchClient.Instance.Statistics().TrackQuery(...) method?
Great to hear that the blog post was useful!
In my solution I am handling the TrackHit call to Find my self (by adding a ajax call when the user clicks a search hit).
Your TrackHit request looks correct, so I would consider filing a bug report to support.
Dmytro - Thanks for the input. I've tried using both the id from a created TrackingContext as well as the id returned through TrackQueryResult, but both methods result in the same outcome; the search is tracked and the click is tracked, but it still shows a 0% click-rate.
Mari - I'm at my wits end so a bug report seems like the next step, thanks!
Just to test I implemented Find with the Alloy-demo using unified search. All worked well and the tracking showed up with the correct amount of click through.
I then proceeded to replace the unified search with a projected one adding the same tracking code I'm using in my project. The generated URLs containing the tracking information were identical, yet the tracking only showed queries and clicks under "Most frequent queries", under "Searches without relevant hits" the click-through rate was 0%.
This makes me suspect that the problem might be related to the TrackQuery call, but the parameters seems correct:
var tags = ServiceLocator.Current.GetInstance<IStatisticTagsHelper>().GetTags().ToList(); _trackingId = new TrackContext().Id; SearchClient.Instance.Statistics().TrackQuery(_trackingQuery, x => { x.Id = _trackingId; x.Tags = tags; x.Query.Hits = totalNumberOfHits; });
Anything I might be missing?
Think I found the source to the problem. Building my querystring parameters I had called GetTags(false) so there was a missmatch between the initial call and the tracking parameter attached to the URL. The clicks where registered but since the tags didn't match it seems the click-through rate counter ignored these clicks.
I have a Find implementation with tracking applied. It seems to work since both the queries and the clicked hits are displayed in the admin UI under "Most frequent queries". However under "Searches without relevant hits" all the queries are listed with a 0% click-rate. I would understand this if the click-tracking wasn't working, but the JavaScript seems to fire correctly and the clicks shows up under each query in the "Most frequent queries"-list.
Is there some additional step that needs to be made in order to get the data for relevant hits displayed correctly?