Try our conversational search powered by Generative AI!

New EPiServer Find TrackHit

Vote:
 

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.

#86417
May 21, 2014 10:34
Vote:
 

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=127.0.0.1&_t_hit.id=Model/_111f4730-f5fe-423c-8646-dfac06a2949f_sv&_t_hit.pos=1

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

#86494
May 22, 2014 15:11
Vote:
 

Hi,

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.

/Marcus

#86535
May 23, 2014 9:30
Vote:
 

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.

#86541
Edited, May 23, 2014 10:07
Vote:
 

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.

#86615
May 26, 2014 18:11
Vote:
 

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?

Thanks

#86626
May 27, 2014 8:54
Vote:
 

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:

http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-Framework/75/Client-resources/Client-resources/

http://world.episerver.com/Blogs/Per-Magne-Skuseth/Dates/2013/3/Is-your-site-Add-On-friendly/

#86638
Edited, May 27, 2014 11:13
Vote:
 

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 ?


                        
#86641
May 27, 2014 11:30
Vote:
 

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: http://domain.se/find_v2/_track?id=oglUExDKwLoPnUGdUQYRmA==&q=kundservice&tags=language:sv|language:7D2DA0A9FC754533B091FA6886A51C0D,siteid:0dc34eb3-df3a-4c69-966b-fbecfa47bd0f|siteid:84BFAF5C52A349A0BC61A9FFB6983A66,language:sv&ip=171.25.151.41&hit.id=XXX_Models_Pages_StandardPage/_eaed2032-38c0-4b58-b854-3e7131ce12a7_sv&hit.pos=1

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?

#86663
May 28, 2014 8:57
Vote:
 

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.

#86843
Jun 03, 2014 9:51
Vote:
 

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

#86862
Jun 03, 2014 18:09
Vote:
 

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: http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=86899&epslanguage=en

#86928
Jun 04, 2014 14:28
Vote:
 

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.

#86953
Jun 05, 2014 10:32
Vote:
 

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

#86965
Jun 05, 2014 11:37
Vote:
 

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.

#89156
Aug 08, 2014 13:37
Vote:
 

Are there any news regarding this issue? 

#113617
Nov 25, 2014 16:51
Vote:
 

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.

#113618
Nov 25, 2014 16:55
Vote:
 

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?

#113687
Nov 26, 2014 15:32
Vote:
 

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? 

#113688
Nov 26, 2014 15:37
Vote:
 

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!

#113976
Dec 02, 2014 14:52
Vote:
 

Håkan.
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?]
_t_hit.id=[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?

#114371
Dec 11, 2014 8:28
Vote:
 

Henrik! 

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

#114372
Dec 11, 2014 8:49
Vote:
 

Hi,

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.

_t_hit.id = 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.

#114438
Dec 11, 2014 15:36
Vote:
 

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

#114452
Dec 11, 2014 19:57
Vote:
 

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').

/Henrik

#115706
Jan 16, 2015 12:11
Vote:
 

Hi,

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&_t_hit.id=[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?

#117170
Feb 12, 2015 15:46
Vote:
 

The arguments to .TrackHit(queryString, hitId) are essentially _t_q and _t_hit.id  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;
});



#117172
Feb 12, 2015 16:32
Vote:
 

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

#117176
Feb 13, 2015 7:43
Vote:
 

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

http://world.episerver.com/blogs/Henrik-Fransas/Dates/2015/2/how-to-do-custom-query-and-click-tracking-with-episerver-find/

#117972
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.