Try our conversational search powered by Generative AI!

Tracking not working when using filters without For() method


We have a problem when trying to track queries that do not use the For() method, instead we use the Filter method. Please note that we are able to track queries that do use the For() method.

The documentation does not state that tracking won't work when not using the For() method, although all of their examples do make use of it, is this a known bug or feature for that matter?



Mar 11, 2015 11:52

The tracking is not very complete in it's solution, so you might have to do like we do and as I have written in this blog

Mar 11, 2015 12:14

Thank you for the quick reply Henrik, it is very much appreciated.

Will your example work for Find 1 R2, sorry I should have mentioned up front that we are using Find 1 R2? I don't seem to have access to the SearchClient.Instance.Statistics() method despite importing the EPiServer.Find.Framework.Statistics namespace. Also, we won't have a query input using the For() method, as their are multiple which we then map using the Filter() method.

Sample code (I have ommitted a couple of lines of code for clarity)

            var query = SearchClient.Instance.Search<Custom_Page_Type_Here>();
            if (!string.IsNullOrEmpty(City))
                    query = query.Filter(x => x.CollegeCity.MatchCaseInsensitive(City));


            query = query.Track();

Just for the sake of clarity, when we do not use the For() method, the query does not show up in the statistics feed in the EPiServer Find backend GUI. So I do have a similar problem that you stated in your blog post.



Edited, Mar 11, 2015 12:53

Any takers?

Mar 19, 2015 14:22

Hi Grant,

We have your ticket inquiry in our system and we deeply apologize for our delayed response. We are looking into it and hope to get an answer for you soon.

Mar 27, 2015 21:47


Tracking only works for the .For() extension simply since when using filters it is in the general case almost impossible to know what was the intended query string as you often add multiple filter statements. If you don't use .For() you have to manually track the query and to do that in Find 1.0.x you do that by calling StatisticsClient.Instance.Track((new TrackContext()).Id,"query", result.TotalMatching) (using the EPiServer.Find.Framework.Statistics.ForInternalUseOnly namespace);


Mar 31, 2015 10:41

Thank you, Richly.

Thanks Henrik, looks like that is what we will have to do.  Henrik Fransas did give a similar example in the link that he provided, but wasn't compatible with Find 1 R2.

Edited, Apr 01, 2015 11:36

Hi Henrik

StatisticsClient.Instance.Track is not available in latest version. 

Can I use track without for in latest version?

Feb 09, 2016 6:40

StatisticsClient.Instance has been moved to SearchClient.Instance.Statistics().

No, what I said earlier is still true that if you want to track a query you need to use For() in order for the api to correclty find the intended querystring.  

Feb 09, 2016 7:52

I had trouble finding SearchClient.Instance.Statistics(), I'm using Find version 12.4.1. For others that might get into the same situation, add the following namespaces:

using EPiServer.Find.Framework;
using EPiServer.Find.Statistics;

Apr 19, 2017 15:35
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.