Try our conversational search powered by Generative AI!

New EPiServer Find TrackHit


In the "New Find" you should be able to track hits just like SiteSeekers "ClickTracking". But i can't find any documentation about how you do this.

I have tried the following but my Find Gui still reports that 0% of my queries ever lead to an hit.

var client = Client.CreateFromConfig();
var statClient = client.Statistics();
var respons = statClient.TrackHit("lorem", "_f4ed1ddd-b4fa-498c-bd1e-69755b44e714_sv");

This code is called via Ajax when the links are clicked just like Siteseeker works.

May 21, 2014 10:34

All links in the search result gets a query string. ?_t_id=oglUExDKwLoPnUGdUQYRmA%3d%3d&_t_q=sokord&_t_tags=language%3a%7clanguage%3a7D2DA0A9FC754533B091FA6886A51C0D%2csiteid%3a0dc34eb3-df3a-4c69-966b-fbecfa47bd0f%7csiteid%3a84BFAF5C52A349A0BC61A9FFB6983A66&_t_ip=

Is this used for TrachHit? Do I have to track it myself or is there any magic behind that take care of this querystring?

May 22, 2014 15:11


There is some magic involved so the only thing that you should be forced to do is use the Track() extension method when issuing the first search request and the link in the search result should send the click tracking away correctly when someone presses on it.


May 23, 2014 9:30

Sounds magic. What is it that take care of the tracking from the querystring? Is it the embedded resources you have added?

If I understand you right I just call Track() when the user clicks the search button.

Edited, May 23, 2014 10:07

If you call .Track() when you search the returned search hit urls will be modified to include tracking information (as was noted by Erik). This information is then picked up by a javascript that is included on the page for the actual tracking.

May 26, 2014 18:11

Håkan: Where is this script injected or loaded? I cannot see any script on my web page. 

Is it something I have to configure to get it to work?


May 27, 2014 8:54

The script is added to the "Footer" Required Client Resources area. This is expected to exist in the page, if that is not the case it would explain the script not being there.

See for instance the following regarding the use and expectations regarding these areas:

Edited, May 27, 2014 11:13

Aha, had missed that part.

Im currently using GetContentResult() to get my results back. The response i get back is obviously missing the required querystring attributes. Is there any way to manually add there to a Url in my viewmodel ?

May 27, 2014 11:30

Ok, I have managed to get the scripts loaded for the Tracking. After a search I see the request to track in fiddler when clicking on a link in the search result:|language:7D2DA0A9FC754533B091FA6886A51C0D,siteid:0dc34eb3-df3a-4c69-966b-fbecfa47bd0f|siteid:84BFAF5C52A349A0BC61A9FFB6983A66,language:sv&ip=

I do get an ok response: {"status":"ok","track_id":"oglUExDKwLoPnUGdUQYRmA==","track_uuid":"yYF8AJYEQYOtBmbUcB-uoA"}

But, where do I see or use the statistics? In EPiServer / Find / Manage(Hantera) there is 0% on all clicked. Have I missed something?

May 28, 2014 8:57

We have been working on this issue and happy to annouce that its fixed and will be pushed in the next release. Thanks for your feedback in this regard. It was very valuable. The next release should be out in the next next coming days.. will let you know.

Jun 03, 2014 9:51

The 8.2.2 version (including a fix for the site/language tagging of track events) is now available in the nuget feed.

Jun 03, 2014 18:09

I have now updated to the lastest version from nuget at put into production. But I cannot see if it works because of the second problem in this thread:

Jun 04, 2014 14:28

There may be some bugs left in this case, I think. Still all search frases show up with 0% under Without relevant hits/Utan relevanta träffar. The same search frase has clicks if I look under Most searches/Oftas förekommande.

Jun 05, 2014 10:32

Is there any way to get TrackTokens attached to the result without using UnifiedSearch/UnifiedSearchHits ? 

Jun 05, 2014 11:37

Are there anyway to get this tokens to apply to custom objects that are indexed?
We have information from another system that is indexed in our site.

Aug 08, 2014 13:37

Are there any news regarding this issue? 

Nov 25, 2014 16:51

We are under the impression that this have been fixed for some time now. If you still have the same problem or different problems with tracking I would contact Support and get assistance from them.

Nov 25, 2014 16:55

Marcus, do you know it there is a way to get it to work for custom object also, meaning things that do not inherit from IContent?

Nov 26, 2014 15:32

Marcus, no actually I cannot find any info about how to attach tracking to ContentResult object-URLS. So, I ask the same question as Henrik and Niklas. I read that you have to extract the SearchResult in order to get the the tracking params injected... Is that correct? Should I contact support about this? 

Nov 26, 2014 15:37

I've had a look at the second wave of questions about doing custom click tracking and my understanding of these questions is that these are based around a scenario where unifiedsearch is not desired, otherwise click tracking should be handled by the system if you call  .Track() when searching with unified search.

The overall approach of what Niklas posted seems workable, but I noticed that the hit id in the example did not have the expected format. (This use does not appear to be covered in the documentation, something we'll have to look into.)

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 (eg "EPiServer_Templates_Alloy_Models_Pages_ProductPage/_cb1b190b-ec66-4426-83fb-24546e24136c_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 (I believe this will be necessary for GetContentResult) it should be possible to do it like this: client.Conventions.TypeNameConvention.GetTypeName(myObj.GetType()) + "/" + client.Conventions.IdConvention.GetId(myObj)

I hope this helps!

Dec 02, 2014 14:52

I tried to apply this, but I do not want to build my own tracking, I want to add the right things to the querystring so my contentresult can work the same way as my unifiedresults.

The arguments that are needed is this:

_t_id= [Is this PageGuid for the content?]
_t_q= [This is easy, just the query search for]
_t_tags=[How do I get this?]
_t_ip=[How do I get this?][This works:  client.Conventions.TypeNameConvention.GetTypeName(myObj.GetType()) + "/" + client.Conventions.IdConvention.GetId(myObj)]
_t_hit.pos=[This I know how to get]

Is this possible to do for ContentResults?

Dec 11, 2014 8:28


If you solve this, please let me know! I have exactly the same problem/question.

Dec 11, 2014 8:49


To do custom tracking one could use client.Statistics().TrackQuery(...) and client.Statistics().TrackHit(...) to do the query and click tracking respectively.

However, to instead just create the query string parameters used with the existing javascript tracking, these are the parameters for tracking a click:

_t_id = trackid, returned from client.Statistics().TrackQuery(...). This means that you may have to call this yourself rather than using the regular .Track() extension.

_t_q = the search query string.

_t_tags = tags for categorization of the collected data. Normally contains site and language tags, ServiceLocator.Current.GetInstance<IStatisticTagsHelper>().GetTags(...) (alt. AddDefaultTags(...)) is probably what you want (as a comma-separated list).

_t_ip = client IP address. = type/id as per above (SearchHit.Type and SearchHit.Id, alternatively client.Conventions.TypeNameConvention.GetTypeName(myObj.GetType()) + "/" + client.Conventions.IdConvention.GetId(myObj)).

_t_hit.pos = the ordinal position the hit was in.

Dec 11, 2014 15:36

Thanks Håkan, will try that out in the morning!

Dec 11, 2014 19:57

If you want to track the Hit without having to track the query using TrackQuery you can get the TrackId by calling (new TrackContext()).Id (This just have to be done in the HttpContext of the User 'clicking').


Jan 16, 2015 12:11


I want to do exactly what Henrik Lindström mentioned above - track a click, but not the query. This is because the item doesn't open as a link, but as an accordion.

I've tried using TrackHit and it returns "ok", but no click is registered in the statistics. Should I include the complete URL, followed by the querystring such as the "regularly tracked links"? Or should it only contain the querystring?

            var thisUrl = @"[URL TO MY PAGE]/?_t_q=[SEARCHQUERY]&_t_tags=&_t_ip=%3a%3a1&[NAMESPACE]_Models_Pages_NewsArticlePage/_086a4296-e6a8-4e8d-b18b-4e985657a243_sv&_t_hit.pos=2";
            var id = (new TrackContext()).Id;
            var trackHitResult = SearchClient.Instance.Statistics().TrackHit(thisUrl, id);

I've even tried posting the exact same url as the one that's used by javascript for the regular .Track(), but it won't register as a click. What am I doing wrong?

Feb 12, 2015 15:46

The arguments to .TrackHit(queryString, hitId) are essentially _t_q and  above (see the previous post detailing the parameters).

To specify the complete set of parameters you may want something like this:

sc.TrackHit(query, hitId, command =>

command.Id = trackId;
command.Ip = ip;
command.Tags = tags;
command.Hit.Position = hitPos;

Feb 12, 2015 16:32

Thank you Håkan. It works great. I got confused about the querystring-parameter and how it was supposed to be formed.

Feb 13, 2015 7:43

I have just published a blog post on how to do this:

Feb 25, 2015 11:16
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.