谷歌分析核心报告第3版 - 如何获得基本网址

时间:2012-08-28 11:22:06

标签: c# google-analytics reporting google-analytics-api

我正在尝试获取Google分析的基本网址,并且由于某些原因我无法让它工作 - 我尝试了以下内容:

                //this is the old url and did use to work ( see   `//https://developers.google.com/analytics/devguides/reporting/core/v2/ )`
    //const string baseUrl = "https://www.google.com/analytics/feeds/data";

                // this is also outdated 
//const string baseUrl = "https://www.googleapis.com/analytics/v2.4/data";

               // this doesnt  seem to work!!! 
const string baseUrl = "https://www.googleapis.com/analytics/v3/data";

这里有一些我写的代码应该构建url

  const string baseUrl = "https://www.googleapis.com/analytics/v3/data/";

                var retailers = affiliateRetailerRepository.GetAffiliateRetailerByScheme(affiliateScheme.Id);
                foreach (var affiliateRetailer in retailers)
                {
                    var query = new DataQuery(baseUrl)
                                    {
                                        Ids = affiliateRetailer.Code,
                                        //todo - custom var may neeed to be put back Dimensions = "ga:customVarName(n),transactionId,ga:productName,ga:productSku,ga:date,ga:hour",
                                        Dimensions = "transactionId,ga:productName,ga:productSku,ga:date,ga:hour",
                                        //Metrics = "ga:itemRevenue,ga:revenuePerItem,ga:itemQuantity",
                                        Metrics = "ga:itemRevenue,ga:itemQuantity",
                                        Segment = "gaid::-8",
                                        Filters = filters,
                                        GAStartDate = startDate.ToString("yyyy-MM-dd"),
                                        GAEndDate = endDate.ToString("yyyy-MM-dd"),
                                        NumberToRetrieve = 10000
                                    };
                    Uri url = query.Uri;

使用上面的内容我得到以下http:

{https://www.googleapis.com/analytics/v3/data/?max-results=10000&dimensions=transactionId,ga:productName,ga:productSku,ga:date,ga:hour&end-date = 2012-08-28&安培;过滤器= GA:源= @ where-to-buy.co,GA:源= @ where-to-purchase.us,GA:源= @ where-to-buy.fr,GA:源= @ wheretopurchase.de,GA:源= @ where-to-buy.es,GA:源= @ wheretopurchase.it,GA:源= @ where-to-purchase.ru,GA:源= @其中至-buy.pl,GA:源= @ where-to-buy.se,GA:源= @ where-to-buy.nl,GA:源= @ where-to-purchase.us,GA:源= @ wheretopurchase .ca& ids = ga:57437629& metrics = ga:itemRevenue,ga:itemQuantity& start-date = 2012-03-13& segment = gaid :: - 8}

我知道我有代码腐烂,因为我没有看过这段代码很长一段时间,但如果有人有任何建议 - 我认为这只是将基本网址更改为最新的一个但是这似乎不起作用。

任何帮助表示赞赏。

编辑:或者,如果有人有一个工作网址,我可以用来构建我的,这也很有用,因为我提到这是一段时间以前放在一起所以它可能意味着我需要重新格式化整个代码符合新的API格式,所以看到一个有用的,然后我可以根据我的需要定制它。 感谢

0 个答案:

没有答案