Google Analytics Account Summary C#

Managment API

As you may already know, the Google Analytics Managment API is where you can get the list of the accounts you or your user has access to. One of the most common uses for this API is to display a list in your application allowing the user to decide which View (Profile) they would like to see data for. The main problem we have had in the past with this is that in order to get a list of Views (Profiles) for the user you must first request a list of Accounts, then a list of web properties with in each account.  Then a list of Views (Profiles) with in each web property. In the past the only way to speed this up was to add fields on each request or to use the notorious ~all command in your quest. But not anymore – the Google Analytics API development team has heard your cries, they have given us the new Google Analytics Account summary report.

Account Summary report

Google Analytics Logo

The new Google Analytics Account Summaries report gives us the best of both worlds. You get a limited amount of data back like with requesting fields. But you get everything back in one request like with using ~all.   It is, in fact, much better then ~all because with one request you get all the data you need to add Account, Web Property, View(profile) selection functionality into your application.


This is served to us via a special cache; I have been assured that the response should be quite fast. This means even if you have a large number of accounts you shouldn’t have time out issues you may have had in the past using ~all.

Max results

The default max results is 1000; this apparently includes all three. We can use the standard next link to get the next set of data.

Requesting Data

I’m not sure if they have released the new version of the Dot net client lib yet to expose this new API.  Once they do, I will add some code for that. In the meantime, the request to Account summaries can be run through a normal HTTP get request. Update: The New Client Libs should be released. I will take a look at posting some sample code tomorrow.{AuthToken}

The Response

As you can see we don’t get all of the information back, but we get enough to build from. I would have liked to see if its Universal vs Classic Analytics account, but that information isn’t in the normal account request either.

"kind": "analytics#accountSummaries",
 "username": "",
 "totalResults": 9,
 "startIndex": 1,
 "itemsPerPage": 1000,
 "items": [
 "id": "45053519",
 "kind": "analytics#accountSummary",
 "name": "Daimto",
 "webProperties": [
 "kind": "analytics#webPropertySummary",
 "id": "UA-45053519-1",
 "name": "",
 "internalWebPropertyId": "75609005",
 "level": "STANDARD",
 "websiteUrl": "",
 "profiles": [
 "kind": "analytics#profileSummary",
 "id": "78110423",
 "name": "Default",
 "type": "WEB"
 "kind": "analytics#profileSummary",
 "id": "81806746",
 "name": "Ecommerce",
 "type": "WEB"
 "kind": "analytics#profileSummary",
 "id": "81692014",
 "name": "Testing",
 "type": "WEB"

C# Code

The code to request this in C#:

ManagementResource.AccountSummariesResource.ListRequest request = service.Management.AccountSummaries.List();
AccountSummaries result = request.Execute();


In my opinion, this is one of the best things they have added since the MetaData API. This will make things a lot easier and faster for a number of development applications. Check back in a week or so – I hope to have a C# example for you by then.

Sample project

The sample project for the Management API shows how to use this.    Google Analytics Management API .Net

About Linda Lawton

My name is Linda Lawton I have more than 20 years experience working as an application developer and a database expert. I have also been working with Google APIs since 2012 and I have been contributing to the Google .Net client library since 2013. In 2013 I became a a Google Developer Experts for Google Analytics.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.