November Happy Hour will be moved to Thursday December 5th.

Track search phrases when using unified search?

Vote:
 

Hi,

Is it possible to track search phrases (most common/without hits) when using unified search? If so, can anyone provide some dummy code on how to achieve this?

Note that I don't want to track clicks or anything, just the search phrases. I tried enabling click tracking but ended up with this ugly URL which I don't want to expose to the end user.

We're using EPiServer CMS 10.10.4.0 along with EPiServer Find 12.6.2.0.

Thanks!

#194758
Edited, Jul 02, 2018 8:28
Vote:
 

Hi Markus Andersson,

May be this helps

public static string TrackQuery(string query, int noOfHits = 1)
        {
            var id = new TrackContext().Id;
            SearchClient.Instance.Statistics().TrackQuery(query, x =>
            {
                x.Id = id;
                x.Tags = GetTags();
                x.Query.Hits = noOfHits;
            });

            return id;
        }
#194782
Jul 03, 2018 3:04
Vote:
 

Hi,

And thank you! It worked the way I expected.

However, I find it weird that you have to do this manually when using Unified Search.

#194790
Jul 03, 2018 11:32
Vote:
 

Glad it helped.

Just one thing GetTags() function is just this line 

ServiceLocator.Current.GetInstance<IStatisticTagsHelper>().GetTags()
#194817
Jul 04, 2018 4:59
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.