I have a database with some google analytics data from our clients. I have three values: AuthKeyId, ProfileId and AnalyticsID. How can I use this data to get the data from google?
Here's the code I tried but I'm getting unauthorized error message:
string authToken = "XXxXXxxx_XXX_xxxx...."; // this seems to be wrong
string feed = "https://www.google.com/analytics/feeds/data";
string ids = "ga:XXXXXXX"; // this is the ID, the correct one
string metrics = "ga:pageviews";
string startDate = "2013-06-25";
string endDate = "2013-07-25";
//Optional:
string sort = "-ga:pageviews";
string feedUrl = string.Format("{0}?ids={1}&dimensions={2}&metrics={3}&sort={4}&start-date={5}&end-date={6}",
feed, ids, dimensions, metrics, sort, startDate, endDate);
webClient.Headers.Add("Authorization", "GoogleLogin " + authToken);
string result = webClient.DownloadString(feedUrl);