Permalink
Browse files

readme

  • Loading branch information...
1 parent 4145a86 commit acdf657195514805a7e333f1fd29bdd139a7e0da @Valve Valve committed Mar 5, 2014
Showing with 20 additions and 5 deletions.
  1. +20 −5 README.md
View
@@ -8,11 +8,11 @@ All potentially long operations are `async/await` methods.
## Usage
-Before you start, make sure you have your Google Analytics `clientId` and `clientSecret` credentials. If you don't, first [https://cloud.google.com/console#/project](get it from Google).
+Before you start, make sure you have your Google Analytics `clientId` and `clientSecret` credentials. If you don't, first get them from Google here: https://cloud.google.com/console#/project
### Authentication
-Using the api requires authenticating via web browser. If you're using Xaml (WPF or Silverlight applications), the code might look like:
+Using the api requires OAuth authentication with web browser. If you're using Xaml (WPF or Silverlight applications), the code might look like:
```
@@ -65,7 +65,8 @@ try {
.WithDimensions(Dimension.Browser);
Result result = await api.Execute(query);
foreach(var row in result.Values){
- Console.WriteLine("I had {0} visits with {1} pageviews on {2} browser", row.Visits, row.Pageviews, row.Browser);
+ Console.WriteLine("I had {0} visits with {1} pageviews on {2} browser",
+ row.Visits, row.Pageviews, row.Browser);
}
}
catch (ConnectionException ex) {
@@ -77,11 +78,25 @@ What does `Api#Execute` return?
It's a `Igooana.Result` object.
This object has two useful properties:
-1. `Values` property - an `IEnumerable<dynamic>`.
+1. `Values` property - an `IEnumerable<dynamic>`. This collection contains the results.
Using `dynamic` allows you to have a collection of objects with all the properties you've queried with metrics and dimensions.
-
Moreover, all properties have their respective CLR types, not strings Google Analytics returns.
+2. `Totals` property - a `dynamic`. This property contains the summed metrics. The names of totals directly correspond to the
+metrics you query.
+
+`Totals` property example:
+
+```c#
+ int profileId = GetProfileId(); // this might use Api.Management to get all your profiles.
+ var query = Query
+ .For(profileId, DateTime.Now.AddDays(-31), DateTime.Now)
+ .WithMetrics(Metric.Visits + Metric.Pageviews)
+ .WithDimensions(Dimension.Browser);
+ Result result = await api.Execute(query);
+ Console.WriteLine("Total Visits: {0}, total page views: {1}", result.Totals.Visits, result.Totals.Pageviews);
+```
+
#### Potential caveat when using silverlight/windows phone data binding to `result.Values`:
There currently is a bug related to it: http://connect.microsoft.com/VisualStudio/feedback/details/522119/databinding-to-dynamic-objects-is-broken

0 comments on commit acdf657

Please sign in to comment.