コード例 #1
0
        public static IEnumerable <ABTestResult> GetResultsByGoal(string goal, string asofdate)
        {
            Dictionary <string, long> impressions = new Dictionary <string, long>();
            Dictionary <string, long> conversions = new Dictionary <string, long>();
            Dictionary <string, long> totalweight = new Dictionary <string, long>();
            Dictionary <string, long> totalviews  = new Dictionary <string, long>();

            ABTestImpressionClient             abtic           = new ABTestImpressionClient();
            CloudTableQuery <ABTestImpression> impressionQuery = abtic.GetAllByGoal(goal, asofdate);

            foreach (var i in impressionQuery.Execute())
            {
                if (impressions.ContainsKey(i.TestID))
                {
                    impressions[i.TestID]++;
                }
                else
                {
                    impressions[i.TestID] = 1;
                }
            }

            ABTestConversionClient             abtcc           = new ABTestConversionClient();
            CloudTableQuery <ABTestConversion> conversionQuery = abtcc.GetAllByGoal(goal, asofdate);

            foreach (var c in conversionQuery.Execute())
            {
                if (conversions.ContainsKey(c.TestID))
                {
                    conversions[c.TestID]++;
                    totalweight[c.TestID] += c.Weight;
                    totalviews[c.TestID]  += c.Views;
                }
                else
                {
                    conversions[c.TestID] = 1;
                    totalweight[c.TestID] = c.Weight;
                    totalviews[c.TestID]  = c.Views;
                }
            }
            List <ABTestResult> results = new List <ABTestResult>();

            foreach (var k in impressions.Keys)
            {
                results.Add(new ABTestResult
                {
                    TestID = k
                    ,
                    UniqueVisitors = impressions.ContainsKey(k) ? impressions[k] : 0
                    ,
                    TotalViews = totalviews.ContainsKey(k) ? totalviews[k] : 0
                    ,
                    ConversionCount = conversions.ContainsKey(k) ? conversions[k] : 0
                    ,
                    ConversionWeightSum = totalweight.ContainsKey(k) ? totalweight[k] : 0
                });
            }

            return(results);
        }
コード例 #2
0
        public void CreateGoalConversion(string goalName, int weight)
        {
            if (request.Cookies[APP_NAME + ".ab." + goalName] != null)
            {
                if (request.Cookies[APP_NAME + "." + goalName + ".converted"] != null)
                {
                    return;
                }

                string testName = request.Cookies[APP_NAME + ".ab." + goalName].Value;

                int views;
                if (!int.TryParse(request.Cookies[APP_NAME + ".ab." + testName + ".views"].Value, out views))
                {
                    views = 1;
                }

                if (testName != null && testName != "")
                {
                    ABTestConversionClient abtcc = new ABTestConversionClient();
                    abtcc.AddConversion(goalName, testName, weight, views);

                    response.Cookies[APP_NAME + "." + goalName + ".converted"].Value = "1";
                }
            }
        }
コード例 #3
0
 public void CreateAutomatedConversion(string goalName, string testName, int weight)
 {
     if (Force)
     {
         if (testName != null && testName != "")
         {
             ABTestConversionClient abtcc = new ABTestConversionClient();
             abtcc.AddConversion(goalName, testName, weight, 1);
         }
     }
 }