Page Events

Page Events

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Analytics.AnalyticsPage
  • Sitecore.Analytics.AnalyticsTracker
  • Sitecore.Context
  • Sitecore.Data.Items.Item

C# Web Control Code

Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (item == null) return;

Sitecore.Analytics.AnalyticsPage page = Sitecore.Analytics.AnalyticsTracker.Current.CurrentPage;
if (page == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("{0}", "C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using : for colon and &#63 for question mark and   for space
output.Write("{0}: {1}", "Item", item.DisplayName);
output.RenderEndTag(); //

output.Write("{0}&#58;&#160;{1}", "Page URL", "<b>" + page.Url + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Has Campaign Event Pages", "<b>" + page.HasCampaignEventPages.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Has Page Events", "<b>" + page.HasPageEvents.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Page Data", "<b>" + page.Data + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Page Navigation", "<b>" + page.Navigation + "</b>");
output.RenderEndTag(); //Div


C# Web Control Real-time Output

Item: Page Events