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?
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
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.
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.
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
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/Blogs/Per-Magne-Skuseth/Dates/2013/3/Is-your-site-Add-On-friendly/
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 ?
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?
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.
The 8.2.2 version (including a fix for the site/language tagging of track events) is now available in the nuget feed.
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
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.
Is there any way to get TrackTokens attached to the result without using UnifiedSearch/UnifiedSearchHits ?
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.
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.
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?
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?
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!
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?
Henrik!
If you solve this, please let me know! I have exactly the same problem/question.
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.
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
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?
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; });
Thank you Håkan. It works great. I got confused about the querystring-parameter and how it was supposed to be formed.
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/
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.
This code is called via Ajax when the links are clicked just like Siteseeker works.