private void Page_Load(object sender, EventArgs e) { // Put user code to initialize the page here ScoreList.DataSource = Sitecore.Context.Database.GetItem("/sitecore/content/Repository/Profile Gathering Pages").Children; ScoreList.DataBind(); TrackerDataContext tc = Sitecore.Analytics.Tracker.DataContext; StringBuilder sb = new StringBuilder(); if (Tracker.CurrentVisit == null) { return; } if (Tracker.CurrentVisit.Keywords != null && !String.IsNullOrEmpty(Tracker.CurrentVisit.Keywords.Text)) { sb.Append("Search keywords for current visit: " + Tracker.CurrentVisit.Keywords.Text + ".<br/>"); } const int checkVisits = 10; Sitecore.Analytics.Data.DataAccess.VisitorLoadOptions vOptions = new Sitecore.Analytics.Data.DataAccess.VisitorLoadOptions { Start = Tracker.CurrentVisit.VisitorVisitIndex - 1, Count = Tracker.CurrentVisit.VisitorVisitIndex - checkVisits, VisitLoadOptions = VisitLoadOptions.Visits }; foreach (VisitorDataSet.VisitsRow visit in Tracker.Visitor.GetVisits(vOptions).Where( visit => visit.VisitId != Tracker.CurrentVisit.VisitId).OrderByDescending( visit => visit.VisitorVisitIndex)) { if (visit.Keywords != null && !String.IsNullOrEmpty(visit.Keywords.Text)) { sb.Append("Last search keywords from " + visit.StartDateTime + " visit: " + visit.Keywords.Text + "<br/>"); return; } } sb.Append("No search keywords for current or last " + checkVisits + " visits.<br/>"); DMS.Text = sb.ToString(); var profilesRows = tc.Profiles; ProfileScores.DataSource = GetProfileKeys("Keynotes"); ProfileScores.DataBind(); }
private void Page_Load(object sender, EventArgs e) { // Put user code to initialize the page here ScoreList.DataSource = Sitecore.Context.Database.GetItem("/sitecore/content/Repository/Profile Gathering Pages").Children; ScoreList.DataBind(); TrackerDataContext tc = Sitecore.Analytics.Tracker.DataContext; StringBuilder sb = new StringBuilder(); if (Tracker.CurrentVisit == null) return; if (Tracker.CurrentVisit.Keywords != null && !String.IsNullOrEmpty(Tracker.CurrentVisit.Keywords.Text)) { sb.Append("Search keywords for current visit: " + Tracker.CurrentVisit.Keywords.Text + ".<br/>"); } const int checkVisits = 10; Sitecore.Analytics.Data.DataAccess.VisitorLoadOptions vOptions = new Sitecore.Analytics.Data.DataAccess.VisitorLoadOptions { Start = Tracker.CurrentVisit.VisitorVisitIndex - 1, Count = Tracker.CurrentVisit.VisitorVisitIndex - checkVisits, VisitLoadOptions = VisitLoadOptions.Visits }; foreach (VisitorDataSet.VisitsRow visit in Tracker.Visitor.GetVisits(vOptions).Where( visit => visit.VisitId != Tracker.CurrentVisit.VisitId).OrderByDescending( visit => visit.VisitorVisitIndex)) { if (visit.Keywords != null && !String.IsNullOrEmpty(visit.Keywords.Text)) { sb.Append("Last search keywords from " + visit.StartDateTime + " visit: " + visit.Keywords.Text + "<br/>"); return; } } sb.Append("No search keywords for current or last " + checkVisits + " visits.<br/>"); DMS.Text = sb.ToString(); var profilesRows = tc.Profiles; ProfileScores.DataSource = GetProfileKeys("Keynotes"); ProfileScores.DataBind(); }