Analytics Configuration

Analytics Configuration

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Context
  • Sitecore.Data.Items.Item
  • System.Collections.Generic.List<T>
  • System.Xml.XmlReader
  • System.Xml.XmlReaderSettings

Analytics Configuration

  • <configuration>
    • <sitecore>
      • <settings>
        • <setting name="Analytics.AutoDetectBots" value="true" />
        • <setting name="Analytics.CampaignQueryStringKey" value="sc_camp" />
        • <setting name="Analytics.EMailFromAddress" value="" />
        • <setting name="Analytics.Enabled" value="true" />
        • <setting name="Analytics.EventQueryStringKey" value="sc_trk" />
        • <setting name="Analytics.LogLevel" value="Error" />
        • <setting name="Analytics.LongRunningRequest" value="5000" />
        • <setting name="Analytics.MaxQueueSize" value="500" />
        • <setting name="Analytics.PerformLookup" value="true" />
        • <setting name="Analytics.PerformLookup.Interval" value="1000" />
        • <setting name="Analytics.PerformLookup.MachineName" value="" />
        • <setting name="Analytics.ReverseDnsLookupTimeout" value="5000" />
        • <setting name="Analytics.Sampling.Percentage" value="100" />
        • <setting name="MaxMind.Encoding" value="ISO-8859-1" />
        • <setting name="MaxMind.Format" value="Country,Region,City,PostalCode,Latitude,Longitude,MetroCode,AreaCode,Isp,Owner,Error" />
        • <setting name="MaxMind.SecurityToken" value="00000000" />
        • <setting name="MaxMind.Url" value="http://sitecore1.maxmind.com/app/sc?i={0}&amp;l={1}" />

Analytics Configuration C# Web Control Code

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

string filePath = Sitecore.IO.FileUtil.MapPath("/App_Config/Include/Sitecore.Analytics.config");

System.Xml.XmlReaderSettings readerSettings = new System.Xml.XmlReaderSettings();
readerSettings.IgnoreComments = true;
readerSettings.IgnoreWhitespace = true;
System.Xml.XmlReader xmlRead = System.Xml.XmlReader.Create(filePath, readerSettings);

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);
output.Write("{0}&#58;&#160;{1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

if (xmlRead.ReadToDescendant("setting"))
{
    do
    {
        //using &#58; for colon and &#160; for space
        output.Write("{0}&#58;&#160;{1}", xmlRead["name"], "<b>" + xmlRead["value"] + "</b><br/>");
    }
    while (xmlRead.ReadToNextSibling("setting"));
}
output.RenderEndTag(); //Div
xmlRead.Close();