Reputation: 163
How to track the user click event on the server side in sitecore? Our requirement is to track few external clicks on the site and register them as goals. I can track the clicks through client side js script but then I would like to achieve this through server side. Any idea as to how to track? Which event\processor actually holds the clicked links info/?
Upvotes: 0
Views: 1381
Reputation: 2635
A click to an external page will not pass through Sitecore anymore, so the system will not be able to track that ootb. Like Marek said, you have a few options to do this yourself. I wrote a blog post on it (https://ggullentops.blogspot.be/2016/02/integrating-addthis-with-sitecore-goals.html) a while ago explaining (with code) how to do this with javascript on the client and a controller to register the goals on the server.
We just post to the controller which takes care of the triggering the goal. Code in short looks like this (check the post for full code - also with obligatory null checks):
var visit = Tracker.Current;
var page = Tracker.Current.Session.Interaction.PreviousPage;
var registerTheGoal = new PageEventItem(goalItem);
var eventData = page.Register(registerTheGoal);
eventData.Data = goalItem["Description"];
eventData.ItemId = goalItem.ID.Guid;
eventData.DataKey = goalItem.Paths.Path;
Tracker.Current.Interaction.AcceptModifications();
Tracker.Current.CurrentPage.Cancel();
Upvotes: 0
Reputation: 27132
There are no events and no processors which are execute when a link on a page is clicked.
You have 2 options if you want to register external link click as Sitecore goal:
Upvotes: 1