views:

737

answers:

2

Hi!

I'm currently building a library around the Google Analytics Data Export API.

When i'm requesting data for a specific profile, this is the response from Google:

<entry>
    <id>http://www.google.com/analytics/feeds/data?ids=ga:3104565&amp;amp;ga:browser=Firefox&amp;amp;start-date=2008-07-10&amp;amp;end-date=2008-08-10&lt;/id&gt;
    <updated>2008-08-09T17:00:00.001-07:00</updated>
    <title type='text'>ga:browser=Firefox</title>
    <link rel='alternate' type='text/html' href='http://www.google.com/analytics'/&gt;
    <dxp:dimension name='ga:browser' value='Firefox'/>
    <dxp:metric confidenceInterval='0.0' name='ga:pageviews' type='integer' value='17547'/>
</entry>

What would be the most logic to return? How would you want to work with the returned data? I have a Entry-object with all the above elements.

The signature for the method is:

public object GetProfileData(int profileId, IEnumerable<Metric> metrics, IEnumerable<Dimension> dimensions, DateTime start, DateTime stop)

Where Metric and Dimension is Enums.

Well, this is actually language agnostic.

If you need any more details, don't hesitate to comment.

A: 

I imagine I'd like having a C# object returned - maybe of type GData or something similar. It could include an integer for the profileId, and DateTimes for the data range. The actual data (pageviews from Firefox?) is a little bit trickier since I have limited experience using the API. How about a Dictionary using the metric as the value and the dimension as the key?

Brad Gignac
Yeah, you seem to understand my problem. I'm going to test with a Dictionary as you said. I will also try to re-phrase my question and post some different xml-responses.
alexn
I wish I could give you a little bit better idea. My experience with the Google Analytics API consists mainly of reviewing it. I'm working on a project on which I'll be using the API right now, but the Analytics portion won't come for a little while. *As far as I can tell*, this is how I might want to use it, but I'll probably have a much better idea in two or three weeks.
Brad Gignac
+1  A: 

An obvious source of inspiration would be the Google Analytics Java Data Export API, as it would be making a similar mapping to what you're aiming for. (XML-to-Java-objects is similar to XML-to-C#-Objects...)

See also this question: http://stackoverflow.com/questions/791125/google-analytics-api-and-net and code here: http://google-gdata.googlecode.com/svn/trunk/clients/cs/src/analytics/

Stobor