Skip to content

Instantly share code, notes, and snippets.

@jgeurts
Created February 17, 2012 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgeurts/1855718 to your computer and use it in GitHub Desktop.
Save jgeurts/1855718 to your computer and use it in GitHub Desktop.
Query the Google Analytics account feed to get a list of available sites
var authFactory = new GAuthSubRequestFactory("analytics", ApplicationName)
{
Token = settings.SessionToken
};
var analytics = new AnalyticsService(authFactory.ApplicationName) { RequestFactory = authFactory };
foreach (AccountEntry entry in analytics.Query(new AccountQuery()).Entries)
{
var account = entry.Properties.First(x => x.Name == "ga:accountName").Value;
if (!model.Sites.ContainsKey(account))
model.Sites.Add(account, new Dictionary<string, string>());
model.Sites[account].Add(entry.ProfileId.Value, entry.Title.Text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment