Last active
August 21, 2017 12:36
-
-
Save mskutta/cf2f16d51493af87245b1df27594d1be to your computer and use it in GitHub Desktop.
Sorting Sitecore Items by Popularity using xDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Sitecore.Analytics; | |
using Sitecore.Diagnostics; | |
using Sitecore.Pipelines; | |
using Website.Logic.Common.Extensions; | |
using Sitecore.Data; | |
using Newtonsoft.Json; | |
namespace Website.Logic.Analytics.Views | |
{ | |
public class ViewPageEventProcessor | |
{ | |
public void Process(PipelineArgs args) | |
{ | |
Assert.ArgumentNotNull(args, "args"); | |
Assert.IsNotNull(Tracker.Current, "Tracker.Current is not initialized"); | |
Assert.IsNotNull(Tracker.Current.Session, "Tracker.Current.Session is not initialized"); | |
Assert.IsNotNull(Tracker.Current.Session.Interaction, "Tracker.Current.Session.Interaction is not initialized"); | |
if (Tracker.Current.Session.Interaction == null) | |
return; | |
var currentPage = Tracker.Current.CurrentPage; | |
if (currentPage == null || currentPage.IsCancelled) | |
return; | |
var pageEventData = currentPage.Register(new Sitecore.Analytics.Data.PageEventData("View") | |
{ | |
ItemId = item.ID.ToGuid(), | |
Text = string.Format("Template ID: {0}", item.TemplateID), | |
DataKey = item.TemplateID.ToString(), | |
Data = item.TemplateID.ToString() | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I've just been reading your blog post and tried to implement as your instructions but I cannot find where "item" used in the block on line 26 is supposed to be declared?