Google Analytics API

1,557 views
Skip to first unread message

otto.gi...@halvarsson.se

unread,
Apr 24, 2009, 4:55:43 AM4/24/09
to Google Data APIs .NET Client Library
Hi,

Is anyone working on support for the Google Analytics Data Export API?

http://code.google.com/apis/analytics/docs/gdata/gdataDeveloperGuide.html

Code already exists for Java and could possibly be ported. Is this
already on someone's to-do list, or is help desired?

Best regards,

Otto Giesenfeld

Frank Mantek

unread,
Apr 24, 2009, 12:32:57 PM4/24/09
to gdata-dotnet-...@googlegroups.com
I am currently not working on this. If you are interested in working
on this, i am more than happy to review your code and submit it into
the depot, but you need to do this first:

http://code.google.com/p/gdata-objectivec-client/wiki/BecomingAContributor

Frank Mantek
Google

sitereactor

unread,
Apr 25, 2009, 5:24:19 PM4/25/09
to Google Data APIs .NET Client Library
Hi Frank and Otto

I have started working on a C# version of the Google Analytics Data
Export API based on the existing Java version. My Java skills are
however not what they have been and a bit rusty to say the least...
If you, Frank, want to review the current code and maybe give me some
pointers about required methods and structure of the analytics project
I would be happy to continue coding and hopefully help contribute
with a working version of hte Data Export API for the .NET client
library.
If anyone wants to help me out, please drop me a comment or on my
blog... I'm currently having some problems porting the Entry class
(es).

Code is available in my latest post about this small porting project:
http://blog.sitereactor.dk/2009/04/25/google-data-apis-and-analytics/

Best regards
Morten Christensen

On 24 Apr., 18:32, Frank Mantek <fman...@gmail.com> wrote:
> I am currently not working on this. If you are interested in working  
> on this, i am more than happy to review your code and submit it into  
> the depot, but you need to do this first:
>
> http://code.google.com/p/gdata-objectivec-client/wiki/BecomingAContri...
>
> Frank Mantek
> Google
> On Apr 24, 2009, at 1:55 AM, otto.giesenf...@halvarsson.se wrote:
>
>
>
> > Hi,
>
> > Is anyone working on support for the Google Analytics Data Export API?
>
> >http://code.google.com/apis/analytics/docs/gdata/gdataDeveloperGuide....
Message has been deleted
Message has been deleted

Frank Mantek

unread,
Apr 28, 2009, 1:31:59 PM4/28/09
to gdata-dotnet-...@googlegroups.com
Looked at the code. Love it. Needs:

a) a patch file :)
b) the signed contributor stuff (below)
c) unittests
d) a sample

Then it would be ready to go. You are using VS2005, so it "should"
work fine for mono/mobile. If you are willing to verify, that is
great, otherwise let me know and i take that on.

Frank Mantek
Google
On Apr 27, 2009, at 1:37 PM, sitereactor wrote:

>
> Sorry about the multiple responses ... I thought I hit the Delete
> button instead of the Send button the first way around...
>
> Best regards,
> Morten Christensen
>
> On 25 Apr., 23:12, sitereactor <elpadrino...@gmail.com> wrote:
>> Hi Otto and Frank
>>
>> I have started working on porting the Google Analytics Data Export
>> API
>> til C# based on the Java code that already exists. My Java skills
>> aren't however not the best in the world and a bit rusty.
>> Looking at the current implementations of other parts of the API like
>> Calendar and Contacts, as well as comparing the Java and C# code I
>> have done the ground work. I do however have some problems with how
>> the structure should be in the C# version, as well as porting some of
>> the methods. So if anyone is interested in helping me out, I would be
>> happy to keep on coding.
>> Maybe you, Frank, would be interested in reviewing the code that I
>> have produced so far and maybe give me some pointers with regards to
>> the structure and required methods for the Entry class(es)?
>>
>> Code is available on my lastest post about this small porting
>> project:http://blog.sitereactor.dk/2009/04/25/google-data-apis-and-analytics/
>>
>> Best regards,
>> Morten Christensen
>>
>> On 24 Apr., 18:32, Frank Mantek <fman...@gmail.com> wrote:
>>
>>> I am currently not working on this. If you are interested in working
>>> on this, i am more than happy to review your code and submit it into
>>> the depot, but you need to do this first:
>>
>>> http://code.google.com/p/gdata-objectivec-client/wiki/BecomingAContri
>>> ...
>>
>>> Frank Mantek
>>> Google
>>> On Apr 24, 2009, at 1:55 AM, otto.giesenf...@halvarsson.se wrote:
>>
>>>> Hi,
>>
>>>> Is anyone working on support for the Google Analytics Data Export
>>>> API?
>>
>>>> http://code.google.com/apis/analytics/docs/gdata/gdataDeveloperGuide
>>>> ....

sitereactor

unread,
May 9, 2009, 4:43:19 PM5/9/09
to Google Data APIs .NET Client Library
Hi Frank

I'm happy to say that I'm done with the implementation of the
analytics api for the .NET client library.
I created an analytics project within the Google Data API SDK, a small
sample application and the unit tests was created by Alex Maitland
(who should also get some credit :-) )
I just signed the individual CLA online, but have a couple questions
about what the patch should contain, which I hope you can answer
before I start wrapping it up.
Should I simply add my source code + unit tests to the solution in the
src-folder, and add my sample to the solution in the sample-folder?
And should I also compile new assemblies for the analytics and
extensions project and place them in the lib/Release folder along with
the sample program or will you handle this? - Because the assembly
versions should probably be changed, right? Currently I have added the
1.4.0.2 version number to the analytics project, but I'm not sure if
it would be an idea to change the analytics project + the extension
project to version 1.4.0.3, now that it has been changed?

Let me know what to include in the patch and i'll have it up on my
server in no time, so we make the analytics api part of the .net
client library ;-)

Best regards,
Morten Christensen

Frank Mantek

unread,
May 11, 2009, 6:58:07 AM5/11/09
to gdata-dotnet-...@googlegroups.com
-> version: look at the other projects, they include a version.cs file
for that information
-> that version.cs should right now be something like 1.4.1.*
indicating that this is work for a new release
-> you list is nearly complete. What is missing is:
-> adding it to the mobile project (only if you are comfortable with
mobile, otherwise i do it)
-> adding it to the make file (only if you are comfortable, otherwise
i do it). The code we ship should run .NET 2.0+ and Mono and Mobile :)
-> the way that stuff is put into the release dir is with a batchfile
(look in misc). Just add your files there. Make sure you create
documentation in the release build, and if possible have some. I will
then add the analytics DLL to the documentation build

Done all that? send me a patch. I take care of the final release etc

Frank

sitereactor

unread,
May 11, 2009, 1:45:44 PM5/11/09
to Google Data APIs .NET Client Library
Hi Frank, thanks for the fast reply.

I have changed the analytics project to point at the same version.cs
as the rest of the projects.
I have not added the analytics project to the mobile solution (I
haven't worked with mobile projects before, so I prefer if you could
add it - although it only seems to be links the the original project
files).
Also, I haven't build any release or debug assemblies because the
mobile version was missing and because I was unsure if my project is
signed correct. I have used a pfx keyfile. The rest of the projects
are signed with an sn keyfile - should this be changed? If so, is this
something you could do?
I was unsuccessfull in building documentation, I couldn't get the
Sandcastle Help File Builder to work even with the pushdoc.cmd. I
created an analytics.xml file in /docs/ - but not really sure if this
is something that is autogenerated. Every method in the vs-project is
commented, but if the analytics.xml should be manually create please
let me know.

Other stuff that is missing:
Adding release dlls to /lib/ (Release, Debug, Mobile) - I have not
built release, debug nor mobile dlls.
Creating mobile analytics project needs to be done.
Nothing changed in the /Google Data API Setup/ folder - don't know if
its necessary.
Updating Makefile (line 34, 56 and 74 added - nothing added for
keyfile and forth, so this needs to be done).

Created/Added:
analytics project + unit tests added to /src/ folder.
new extensions added to project: aggregates.cs, dimension.cs,
metric.cs, property.cs, tableid.cs and tablename.cs.
gdatanametable.cs updated.
analytics sample project added to the /samples/ folder.
gdata-sharp-analytics.pc.in created in /misc/ folder.
Analytics.exe added to the /lib/Release/ folder (might need to be
recompiled with new assemblies).
Updated BaseLiveTestClass and unittests.dll.config to hold AccountId
for analytics tests.
Updated pushdlls.cmd in /misc/ folder for analytics (line 26, 44, 69,
75 and 107 added).

Here is a link to the patch file: http://www.sitereactor.dk/media/google-gdata-analytics-patch.zip
Here is a link to a package with the full svn trunk with my changes:
http://www.sitereactor.dk/media/Google GData.zip

I hope all the above is enough to get my code added to the trunk and
future release. If there is anything else you need or that I missed
please let me know :)

Best regards,
Morten Christensen

Frank Mantek

unread,
May 12, 2009, 8:09:53 AM5/12/09
to gdata-dotnet-...@googlegroups.com
btw, to get credit:

-> feel free to modify the releasenotes html file and add what was
done, and who did it. Also, adding you credentials to the files you
are adding, as long as you do not violate the license, is just fine by
me.

Frank
On May 9, 2009, at 10:43 PM, sitereactor wrote:

>

sitereactor

unread,
May 12, 2009, 10:40:40 AM5/12/09
to Google Data APIs .NET Client Library
Cool, i'll add a couple of things and send you a new patch, okay?

Morten

sitereactor

unread,
May 15, 2009, 2:30:40 PM5/15/09
to Google Data APIs .NET Client Library
Hi Frank,

Okay, so I made some small updates to the files. Primarily adding
credentials and some comments/documentation that was missing.
A couple of unit tests has been added and the username/password/
accountid is now retrieved from the unittest.dll.config file.
I added a couple of lines in the release notes under version 1.5.0.1
(dont know if this is the correct version number) - please feel free
to change it.
Other then that I hope you can make the final adjustments as per my
last post to get the analytics api added to the trunk and get a
release out there :-)

Here are the links for the updated patch for the trunk and a zipped
version of the full trunk should you need it:
Patch: http://www.sitereactor.dk/media/google-gdata-analytics-updated.zip
Zipped trunk: http://www.sitereactor.dk/media/Google-GData-updated.zip

Please let me know if you need me to change/add some more things or
when the patch is added to the trunk.

Thanks

Best regards
Morten Christensen

Frank Mantek

unread,
May 19, 2009, 7:01:54 AM5/19/09
to gdata-dotnet-...@googlegroups.com
working on it. Need to move things you added to the extensions project
into the analytics project, but beside that it looks good so far. Will
take me at least until eow (busy right now with something else as well).

Frank

Frank Mantek

unread,
May 20, 2009, 5:44:38 AM5/20/09
to gdata-dotnet-...@googlegroups.com
I am pushing this as we speak into subversion (setup coming when the
point below is clarified).

I think this is a great start, but i do not want to release (setup
release, announce etc) anything anymore without a Generics/Vertical
model (like YouTube and Contacts). The feedback we got so far is that
most people find the protocol close model not appealing, and I hope
that the new Request oriented model I introduced (Google.YouTube and
Google.Contacts) to be more useful.

So, i like to have a Google.Analytics namespace, that uses the
Requestmodel etc. That's a thin layer on top, with helpers that
actually do the most common operations easily (especially automatic
paging).

Are you guys up to it? It would be great if you could come up (as you
know the API and how/what to use it for probably better than me) with
a file similiar to contactsrequest.cs. I understand if you do not have
the time, but heck, i can always ask for it :)

Thanks a lot for the good work on this so far.

Frank
On May 15, 2009, at 8:30 PM, sitereactor wrote:

>

sitereactor

unread,
May 20, 2009, 10:04:54 AM5/20/09
to Google Data APIs .NET Client Library
Hi Frank,

I'll have a look at it tomorrow or doing the weekend.
I actually used the Calender project as a source of comparison, but
i'll take a cook at contactsrequest.cs and the Google.YouTube
namespace.

Just one thing: Have you already put mine and your changes into
subversion? You wrote something about moving the extensions, so I just
want to make sure I don't work on some code that you have to change
again. Or you can just tell me how you want the extensions placed,
because I can easily move it to the analytics project so everything is
contained within this project if thats what you want....?

Best regards,
Morten Christensen

Frank Mantek

unread,
May 20, 2009, 10:45:00 AM5/20/09
to gdata-dotnet-...@googlegroups.com
Just checked in, wanted to ask you to verify anyhow :)

Frank

sitereactor

unread,
May 20, 2009, 2:00:34 PM5/20/09
to Google Data APIs .NET Client Library
Sure thing.
I'll will have a look at making a analyticsrequest.cs
(Google.Analytics) during the weekend and i'll see if Alex has time to
wrap up some unittests :)

Morten Christensen

Alex Maitland

unread,
May 21, 2009, 3:50:30 AM5/21/09
to Google Data APIs .NET Client Library
Having a strongly typed model sounds like a great idea.

What about including some of the default reports that the analytics
web interface includes?

We could provide a generic model that encapsulates the basic
functionality (eg. paging), extending this to provide a few generic
reports and also allowing the user to extend this to write their own
custom reports.

Example:
- AbstractAnalyticsRequest
-- BrowserMetricsRequest (page views/per browser for a time period,
could even include some of the calculations that the web interface
does)

I know this is more work, and we should probably focus on the core
functionality for now. I do think it would add value to the analytics
api.

Thoughts?

Alex Maitland

unread,
May 20, 2009, 8:10:30 PM5/20/09
to Google Data APIs .NET Client Library
Hi Frank,

Just looking at the latest trunk version and it seems that
analytics.cs is missing from the sample directory.

http://google-gdata.googlecode.com/svn/trunk/clients/cs/samples/analytics/

Any chance of getting this added?

As for the Request objects, makes sense to provide a strongly typed
model. I'll see what time I have to contribute over the weekend.

Cheers,
Alex M

Frank Mantek

unread,
May 21, 2009, 8:06:17 AM5/21/09
to gdata-dotnet-...@googlegroups.com
providing the typed model is easy as hell, if you know HOW you want to
use the service. You give me an idea about common operations, and i
can write this in an hour. Or, give it a whirl yourself. The current
baseclasses for this (feedmodel.cs) provide automatic paging for you.

Just added the missing file.

Frank

Frank Mantek

unread,
May 25, 2009, 10:31:19 AM5/25/09
to gdata-dotnet-...@googlegroups.com
I just checked in a first version of analyticsrequest.cs and a bunch
of changes to the data classes (primarily, there was redundant code,
and i just shrank it down).

I like everyone who was involved to:

a) verify that i have not broken you guys :)

b) look at the analyticrequest.cs file. There is a new namespace now,
Google.Analytics. You should be able to do this now:

RequestSettings settings = new RequestSettings("yourapp", "username",
"password");
settings.Autopage = true;

AnalyticsRequest f = new AnalyticsRequest(settings);
Feed<Account> feed = f.GetAccounts();

foreach (Account a in feed.Entries)
{
Console.WriteLine(a.TableId);
Console.WriteLine(a.AccountName);
etc.....
}

I am going to do the same thing for the DataEntry class (not done
yet). If you have some good ideas for some default/common operations,
let me know. I checked in the code, new DLLs to play with, but have
not updated the helpfile yet....

Frank

sitereactor

unread,
May 25, 2009, 1:45:34 PM5/25/09
to Google Data APIs .NET Client Library
Looks good.
I could only find one thing, and its probably my own typo:
In the DataEntry class there is a method called
"getAccountExtensionValue", which should be "getDataExtensionValue" if
it should remain.

I haven't run the unit tests after your changes, but there doesn't
look to be anything signically different.

If you do the same thing for the DataEntry class as you have done for
the AccountEntry I think the API will be much simpler to use.
I currently don't have any ideas for common operations, but if you are
thinking of including the DataQuery it might be an idea to make some
overload methods like:
public DataQuery GetDataQuery(string metric, string dimension,
DateTime startDate, DateTime endDate)
public DataQuery GetDataQuery(string metric, string dimension, string
sort, DateTime startDate, DateTime endDate)
public DataQuery GetDataQuery(string metric, string dimension, string
sort, string filter, DateTime startDate, DateTime endDate)
however not really sure if it will fits into the context of the
request class.

I will take a closer look at the youtuberequest implementation, and
get back to you if I get inspired. Maybe Alex have some ideas for
default/common operations.

- Morten
Reply all
Reply to author
Forward
0 new messages