Episerver Find Search Statistics Click tracking search result issue


I am trying to implement click tracking using EPiServer Find for a CMS application. I am able to generate the statistics but the page name in the search results is showing up as page not found.

Below is a screen shot for reference: https://www.screencast.com/t/ywkYtn9L

Any info on this will be of great help to me.

#189640 Mar 21, 2018 22:26
  • Member since: 2007

    If you try to do the search and make sure that you are using it as a non logged in user and click on the page in the result, do you see the page?

    It might be so that the result is pages that can't be accessed by ordinary users

    #189648 Mar 22, 2018 9:15

    If you try to do the search and make sure that you are using it as a non logged in user and click on the page in the result, do you see the page? 

    It might be so that the result is pages that can't be accessed by ordinary users

    Yes I do see the page, the intended site is a blog so a non logged user can access almost all pages. 

    @Henrik Fransas: Thank you for your reply, I actually went over your articles to implement this. 

    Another thing is that I am creating the blog article pages dynamically from an xml file. I have created a custom page for it, and also has a corresponding viewmodel for the page. Below is the sample of my code when I use search:

    Code to track the query and populate HitId and HitType properties

    var searchResults = client.Search<ArticlePage>().For(q).Select(x => new ArticleListTrackViewModel
    ArticleCategory = x.ArticleCategory,
    Created = x.Created,
    PageTitle = x.PageTitle,
    ArticleLink = x.ExternalURL,
    Author = ArticleHelper.GetAuthorName(x.Author),
    HitType = "ArticlePage"    (I am hard coding this)


    var hits = searchResults.Hits;
    foreach( var obj in hits)
     obj.Document.HitId = ArticleHelper.GetPageID(obj.Document.PageTitle); (The helper gets the PageGuid)

    model.TrackId = new TrackContext().Id;
    SearchClient.Instance.Statistics().TrackQuery(q, x =>
    x.Id = model.TrackId;
    x.Tags = ServiceLocator.Current.GetInstance<IStatisticTagsHelper>().GetTags(false);
    x.Query.Hits = searchResults.TotalMatching;
    model.NumberOfHits = searchResults.Hits.Count();
    model.Results = searchResults;

    return View(model);

    And on clicking the tracker the below mentioned action method is triggered, which in turn calls a helper function:

    Controller Code:

    public class ClickTrackingController : Controller
    public JsonResult Track(string query, string hitId, string trackId)
      Helper.TrackClick(query, hitId, trackId);

      return Json(new { msg = "Click tracked" }, JsonRequestBehavior.AllowGet);
    catch (Exception e)
    return Json(new { Success = false }, JsonRequestBehavior.AllowGet);

    Helper funtion code:

    public static void TrackClick(string query, string hitId, string trackId)
    SearchClient.Instance.Statistics().TrackHit(query, hitId, command =>
    command.Hit.Id = hitId;
    command.Id = trackId;
    command.Ip = "";
    command.Tags = ServiceLocator.Current.GetInstance<IStatisticTagsHelper>().GetTags(false); // don't get all tags
    command.Hit.Position = null;

    If you see I am hard coding the HitType and using a helper method to get the PageGuid to assign the value to HitId. I was having the same problem as you have mentioned in your article:https://world.episerver.com/forum/developer-forum/EPiServer-Search/Thread-Container/2015/5/using-projections-with-hitid-and-hittype/. But since I use a view model I am not sure if I can use the approach in the article. 

    Also, the query string parameters are as shown below:

    1. query: sample
    2. hitId: ProjectName.Models.PageTypes.ArticlePage/94cb8651-9224-4531-b60d-29dc66eeba93   (PageType / PageGuid)
    3. trackId: 1B2M2Y8AsgTpgAmY7PhCfg== (this matches the track id used in TrackQuery)

    A sample URL looks like the one mentioned below:


    #189671 Edited, Mar 22, 2018 15:21

    I had this issue recently and opened a support ticket for it.  I was told that I needed a "SearchTitle" property in my index model, and that whatever I loaded into that property would be what showed in the statistics where I was seeing "Page not found".  It worked!  Maybe you need to do the same ?

    #190731 Apr 16, 2018 15:59