Skip to content

Instantly share code, notes, and snippets.

@komainu85
Created May 26, 2015 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komainu85/c21ca6238a7793fd674f to your computer and use it in GitHub Desktop.
Save komainu85/c21ca6238a7793fd674f to your computer and use it in GitHub Desktop.
public class DmsManager : IDmsManager
{
readonly Guid _searchPageEventGuid = Sitecore.Context.Database.GetItem("{0C179613-2073-41AB-992E-027D03D523BF}").ID.Guid;
readonly Guid _downloadPageEventGuid = Sitecore.Context.Database.GetItem("{FA72E131-3CFD-481C-8E15-04496E9586DC}").ID.Guid;
private ICurrentPageContext CurrentPage()
{
return Tracker.Current.Session.Interaction.CurrentPage;
}
public void RegisterSearchTerm(string searchterm, ID itemId)
{
if (searchterm != null)
{
if (Tracker.IsActive && Tracker.Current.Contact != null && Tracker.Current.Session != null)
{
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 (Tracker.IsActive && Tracker.Current.Contact != null && Tracker.Current.Session != null)
{
var page = CurrentPage();
page.Register(new PageEventData("Download", _downloadPageEventGuid) { ItemId = itemId.ToGuid(), Data = downloadedResourceText, DataKey = downloadedResourceText, Text = "Resource Downloaded" });
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment