private static void UpdateTestSettings(MultivariateTestDefinitionItem testDefinition) { Assert.ArgumentNotNull((object)testDefinition, "testDefinition"); if (WebEditUtil.Testing.CurrentSettings != null) { return; } var isTestRunning = TestingUtil.MultiVariateTesting.IsTestRunning(testDefinition); WebEditUtil.Testing.CurrentSettings = new WebEditUtil.Testing.TestSettings( testDefinition, WebEditUtil.Testing.TestType.Multivariate, isTestRunning); if (!isTestRunning) { return; } var testDefinitionItem = (TestDefinitionItem)testDefinition; Assert.IsNotNull(testDefinitionItem, "testDefinitionItem"); PageStatisticsContext.SaveTestStatisticsToSession( PageStatisticsContext.GetTestStatistics(testDefinitionItem, true, false)); }
public void SetGoal(string currentItemId, string linkedId, string goalId) { if (string.IsNullOrEmpty(currentItemId) || string.IsNullOrEmpty(linkedId) || string.IsNullOrEmpty(goalId)) { return; } Database db = Sitecore.Context.Database; if (db == null || db.Name.ToLower() == "core") { db = Sitecore.Context.ContentDatabase; } if (db == null) { return; } Item currentItem = SitecoreItemFinder.GetItem(db, currentItemId); Item linkedItem = SitecoreItemFinder.GetItem(db, linkedId); Item goalItem = SitecoreItemFinder.GetItem(db, goalId); if (currentItem.IsNull() || linkedItem.IsNull() || goalItem.IsNull()) { return; } PageStatisticsContext pageStatistics = new PageStatisticsContext(); pageStatistics.SetGoalMet(currentItem, linkedItem, goalItem, Tracker.CurrentVisit.VisitId, Tracker.CurrentVisit.VisitorId); }
public Hashtable GetInformation(string visitId) { List <Hashtable> goals = new List <Hashtable>(); List <Hashtable> goals2 = new List <Hashtable>(); PageStatisticsContext pageStatistics = new PageStatisticsContext(); Sitecore.SharedSource.Analytics.Context.Visit visit = pageStatistics.GetVisit_ById(visitId); if (visit == null) { return(null); } Sitecore.SharedSource.Analytics.Context.Visitor visitor = pageStatistics.GetVisitor_ById(visit.VisitorId.ToString()); if (visitor == null) { return(null); } List <VisitGoal> visitGoalsMet = pageStatistics.GetGoalsMetDuringVisit(visit.VisitId).OrderByDescending(x => x.GoalMetDate).ToList(); foreach (VisitGoal visitGoal in visitGoalsMet) { Hashtable goalTable = new Hashtable(); goalTable.Add("Date", visitGoal.GoalMetDate.Value.ToString("MMMM dd, yyyy H:mm:ss")); goalTable.Add("Goal", visitGoal.GoalName); goalTable.Add("Amount", visitGoal.EngagementValue); goals.Add(goalTable); } const int startSecondColumnAt = 3; if (goals.Count > startSecondColumnAt) { double dividedValue = ((double)goals.Count) / 2; int amountPerColumn = (int)Math.Round(dividedValue, 0, MidpointRounding.AwayFromZero); goals2 = goals.GetRange(amountPerColumn, goals.Count - amountPerColumn); goals = goals.GetRange(0, amountPerColumn); } Hashtable hashtable = new Hashtable(); hashtable.Add("VisitorEngagementValue", pageStatistics.GetVisitorEngagementValue(visitor.VisitorId).ToString("N0")); hashtable.Add("VisitEngagementValue", pageStatistics.GetVisitEngagementValue(visit.VisitId).ToString("N0")); hashtable.Add("Goals", goals); hashtable.Add("Goals2", goals2); return(hashtable); }
protected override void OnInit(EventArgs e) { DebugInfoEvent += new EventHandler(AnalyticsControl_DebugInfoEvent); //set database if (Sitecore.Context.ContentDatabase != null) { _database = Sitecore.Context.ContentDatabase; } else { _database = Sitecore.Context.Database; } //set context _pageStatisticsContext = new PageStatisticsContext(); }
private static void UpdateTestSettings(MultivariateTestDefinitionItem testDefinition) { Sitecore.Diagnostics.Assert.ArgumentNotNull(testDefinition, "testDefinition"); if (Sitecore.Web.WebEditUtil.Testing.CurrentSettings != null) { return; } bool flag = TestingUtil.MultiVariateTesting.IsTestRunning(testDefinition); Sitecore.Web.WebEditUtil.Testing.CurrentSettings = new Sitecore.Web.WebEditUtil.Testing.TestSettings(testDefinition, Sitecore.Web.WebEditUtil.Testing.TestType.Multivariate, flag); if (!flag) { return; } TestDefinitionItem testDefinitionItem = (TestDefinitionItem)testDefinition; Sitecore.Diagnostics.Assert.IsNotNull(testDefinitionItem, "testDefinitionItem"); PageStatisticsContext.SaveTestStatisticsToSession(PageStatisticsContext.GetTestStatistics(testDefinitionItem, true, false)); }