Exemplo n.º 1
0
        public IEnumerable <Goal> GetGoalCompletions(IEnumerable <Goal> goals, string start, string end)
        {
            var metrics = "ga%3Avisits,";

            foreach (var goal in goals)
            {
                metrics += "ga%3Agoal" + goal.Number + "Completions,";
            }

            metrics = metrics.TrimEnd(',');

            var data = _dataProvider.SendRequest(_token, "https://www.google.com/analytics/feeds/data?ids=ga%3A" + _profile.Value + "&metrics=" + metrics + "&start-date=" + start + "&end-date=" + end + "&max-results=50");

            var parser = new AnalyticsGoalParser();
            var visits = parser.ParseVisits(data);

            var completions = parser.ParseCompletions(data);

            foreach (var completion in completions)
            {
                var goal = goals.FirstOrDefault(x => x.Number == completion.Key);
                goal.Completions    = completion.Value;
                goal.ConversionRate = Math.Round((completion.Value / (double)visits) * 100, 2);

                yield return(goal);
            }
        }
Exemplo n.º 2
0
        public IEnumerable <Goal> GetGoals()
        {
            var data = _dataProvider.SendRequest(_token, "https://www.google.com/analytics/feeds/datasources/ga/accounts/~all/webproperties/~all/profiles/~all/goals");

            Debug.WriteLine(data);

            var parser = new AnalyticsGoalParser();
            var goals  = parser.ParseGoals(data);

            return(goals);
        }
Exemplo n.º 3
0
        public Goal GetGoalCompletions(Goal goal, string end)
        {
            var metrics = string.Format("ga%3Avisits,ga%3Agoal{0}Completions", goal.Number);
            var data    = _dataProvider.SendRequest(_token, "https://www.google.com/analytics/feeds/data?ids=ga%3A" + _profile.Value + "&metrics=" + metrics + "&start-date=" + goal.Updated.ToShortDateString() + "&end-date=" + end + "&max-results=50");

            var parser = new AnalyticsGoalParser();

            var visits      = parser.ParseVisits(data);
            var completions = parser.ParseCompletions(data);

            foreach (var completion in completions)
            {
                goal.Completions    = completion.Value;
                goal.ConversionRate = Math.Round((completion.Value / (double)visits) * 100, 2);
            }

            return(goal);
        }
        public IEnumerable<Goal> GetGoalCompletions(IEnumerable<Goal> goals, string start, string end)
        {
            var metrics = "ga%3Avisits,";
            foreach(var goal in goals)
            {
                metrics += "ga%3Agoal" + goal.Number + "Completions,";
            }

            metrics = metrics.TrimEnd(',');

            var data = _dataProvider.SendRequest(_token, "https://www.google.com/analytics/feeds/data?ids=ga%3A" + _profile.Value + "&metrics=" + metrics + "&start-date=" + start + "&end-date=" + end + "&max-results=50");

            var parser = new AnalyticsGoalParser();
            var visits = parser.ParseVisits(data);

            var completions = parser.ParseCompletions(data);

            foreach(var completion in completions)
            {
                var goal = goals.FirstOrDefault(x => x.Number == completion.Key);
                goal.Completions = completion.Value;
                goal.ConversionRate = Math.Round((completion.Value / (double)visits) * 100, 2);

                yield return goal;
            }
        }
        public IEnumerable<Goal> GetGoals()
        {
            var data = _dataProvider.SendRequest(_token, "https://www.google.com/analytics/feeds/datasources/ga/accounts/~all/webproperties/~all/profiles/~all/goals");
            Debug.WriteLine(data);

            var parser = new AnalyticsGoalParser();
            var goals = parser.ParseGoals(data);

            return goals;
        }
        public Goal GetGoalCompletions(Goal goal, string end)
        {
            var metrics = string.Format("ga%3Avisits,ga%3Agoal{0}Completions", goal.Number);
            var data = _dataProvider.SendRequest(_token, "https://www.google.com/analytics/feeds/data?ids=ga%3A" + _profile.Value + "&metrics=" + metrics + "&start-date=" + goal.Updated.ToShortDateString() + "&end-date=" + end + "&max-results=50");

            var parser = new AnalyticsGoalParser();

            var visits = parser.ParseVisits(data);
            var completions = parser.ParseCompletions(data);

            foreach(var completion in completions)
            {
                goal.Completions = completion.Value;
                goal.ConversionRate = Math.Round((completion.Value / (double)visits) * 100, 2);
            }

            return goal;
        }