Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sitecore DMS Page Events Manager
public class DmsPageEventsManager : IDmsPageEventsManager
{
readonly Guid _searchPageEventGuid = new Guid("{0C179613-2073-41AB-992E-027D03D523BF}");
readonly Guid _downloadPageEventGuid = new Guid("{FA72E131-3CFD-481C-8E15-04496E9586DC}";
private ICurrentPageContext CurrentPage()
{
return Tracker.Current.Session.Interaction.CurrentPage;
}
public void RegisterSearchTerm(string searchterm, ID itemId)
{
if (searchterm != null)
{
if (TrackerEnabled())
{
var page = CurrentPage();
page.Register(new PageEventData("Search", _searchPageEventGuid) { ItemId = itemId.ToGuid(), Data = searchterm, DataKey = searchterm, Text = searchterm });
}
}
}
public void RegisterDownload(string downloadedResourceText, ID itemId)
{
if (downloadedResourceText != null)
{
if (TrackerEnabled())
{
var page = CurrentPage();
page.Register(new PageEventData("Download", _downloadPageEventGuid) { ItemId = itemId.ToGuid(), Data = downloadedResourceText, DataKey = downloadedResourceText, Text = "Resource Downloaded" });
}
}
}
public void RegisterPageEvent(ID pageEventId, string pageEventName, ID itemId, string text, string data)
{
if (!pageEventId.IsNull)
{
if (TrackerEnabled())
{
var page = CurrentPage();
page.Register(new PageEventData(pageEventName, pageEventId.Guid) { ItemId = itemId.ToGuid(), Data = data, DataKey = data, Text = text });
}
}
}
private static bool TrackerEnabled()
{
return Tracker.IsActive && Tracker.Current.Session != null && Tracker.Current.Session.Interaction != null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment