I've been trying to get the statistics recorded properly and haven't had much luck. At this point we're just trying to get the query statistics, not the hit.
I tried variations of this
ITypeSearch<LayoutPageData> q = SearchClient.Instance.Search<LayoutPageData>();
// standard filters
q = q.FilterOnCurrentSite().FilterForVisitor().ExcludeDeleted().CurrentlyPublished();
IContentResult<LayoutPageData> results = q.Track().GetContentResult<LayoutPageData>();
But this doesn't track anything. I'm trying to understand what the scope parameter for Track() is. The class library documetnation is very unhelpful. My hope is it would provide examples like Microsoft does.
This code does work, but records it's statistics under "All Websites" .
Is there a way of supplying an appropriate parameter in TrackQuery() with the commandAction? If so, is it a tag?
I've checked out Henrik's great article here as well:How to do custom query and click tracking with EPiServer Find
Any help would be greatly appreciated.
I've also tried this, which doesn't seem to do the trick.
SearchClient.Instance.Statistics().TrackQuery(queryText, cmd =>
cmd.Id = new TrackContext().Id;
cmd.Tags = _tagHelper.GetTags();
cmd.Query.Hits = results.TotalMatching;
Are you still having issues with tracking? If you're using a demo index we've been having issues lately with delayed track requests. In some cases there tracking requests hasn't been visible in the statistics until a couple of days later.
Thanks for getting back to me. I haven't had any luck, but I don't think this isn't a demo instance. Support setup a development one for us. When the statistics show for "All Websites", it's an instant response. I can't however get it to show up in one of the two sites we have setup.
You should use GetTags(false) to not send all language and site tags. It's only supported to send in one Language ID and one Site ID.
If you still experience this perhaps capturing those requests against _track API endpoint and share them here.
Sorry, I should have accepted an answer. I've done that now. Thank you for all the help dada.