Home > Google API > Google Data APIs and Analytics

Google Data APIs and Analytics

Updated May 7th 2009 – see here.
I was real happy to see the annoucement of the Google Analytics API and anxious to get started.
As-is the API is available through the JavaScript and Java programming languages, as well as open to protocol interactions using raw XML and HTTP. This is all great, but i’m a .NET developer and would of course have liked to see the analytics API implemented in the Google Data APIs .NET Client Library, as was done with the Java (1.31.1) version of the library.

Since the full source for the Java version is available I thought I would have a look and maybe give a shot at porting it to C#. So I gave myself and the code 4 hours to see how far I could get implementing the analytics api in the .NET client library. Two hours in it was clear that my Java skillsĀ  aren’t as good as they used to be… I don’t think I have actually touched Java since 2003. But I continued anyway, as the code spawned.
I created the Service class, which uses AccountFeed and DataFeed that uses AccountQuery and DataQuery respectively. And then there is the Entry class(es)… this is there I started to see double – wish I had a better recollection of Java even though it is very similar to C#. I compared alot of the Java and C# implementations of the Feed and Query classes of google calendar and contact, but two hours in my head started spinning…

Before I have a chance to have someone a bit more skilled in Java then me, I will proably not do to much more work on porting the analytics api. But if anyone should be interested in helping out, please give me a buzz. If you wanna review the current code and give me an indication of the direction, please feel free to do so.

Also, if you want to contribute please drop a comment.
I will be happy to do some more coding when I get back on track with how the structure should be in the C# version.

Here is a zip-file of the project (VS2005) – the source code that come with the Google .NET client library.

I will write another post within the next couple of dayes, which goes a bit more into details about the code. AND hopefully have time to make some unit tests…

Updated May 7th 2009: Please download the new zip with the complete project – VS2005 client library including analytics.
The previous file (and project) was very much a work in progress. I have continued the work by studying the other implementations and the existing Java implementation to build a .NET version of the analytics api, which is now complete.
It currently lacks unit tests, so if anyone wants to join in please feel free to do so. I probably won’t have to to do unit testing for the next 3 weeks, but I do plan to write a follow-up post on how to use the api using .NET. Also, in the Java implementation the dxp:aggregates node is implementated so you can access it as an object – this is currently not implemented. Please let me know if you need it.

Categories: Google API Tags: , ,
  1. May 2, 2009 at 6:01 am | #1

    Please send some client code for your analytics assembly and a few notes if possible :)

    • May 7, 2009 at 6:56 am | #2

      Hi Phil,

      Thanks for the reply.
      I plan to write a post on the current implementation of the analytics api and how to use it to get data. Please check back next week.
      Meanwhile, a new VS2005 project and newly compiled assemblies has been attached to the post. So if you download the previously attached code, please download the new one.

  2. Alex M
    May 7, 2009 at 2:23 am | #3

    Found your post via google, nice work on the analytics API extension. Hope they get included in the official release.

    Think I found a bug in the way the Feed is assigned, there is no condition to check which feed type needs to be generated (Last two lines, of the code posted below).

    protected void OnNewFeed(object sender, ServiceEventArgs e)
    {
    Tracing.TraceMsg(“Created new Documents Feed”);
    if (e == null)
    {
    throw new ArgumentNullException(“e”);
    }
    e.Feed = new AccountFeed(e.Uri, e.Service);
    e.Feed = new DataFeed(e.Uri, e.Service);
    }

    Also some unit tests to show sample usage would be awesome (I’m working on some now).

    • May 7, 2009 at 6:53 am | #4

      Hi Alex, thanks for the reply.

      You are right about the condition to check which feed needs to be generated. The previously attached code was very much a work in progress, so please disregard that code. I just finished the implementation last night and a new file has been attached to the post. Please download this new project and you should see a complete implementation.
      I plan to write a post about the implementation of the analytics api and how to get data within this week (hopefully).

      It would be really nice if you could create some unit tests. I currently don’t have the time to do so …. and its also the only thing missing to get this code included in the official release.

      Best regards,
      Morten Christensen

      • Alex M
        May 7, 2009 at 7:42 am | #5

        Awesome thanks, I’ll see what I can do about writing some additional unit tests (I’ve got a hand full, far from comprehensive). Are you specifically targeting vs2005?

        I had your previous version working with a few minor tweaks. Will checkout the updated version now.

        Will get back to you shortly.

      • May 7, 2009 at 8:52 am | #6

        Cool … You are welcome to send me your current test cases (then i’ll work them into the project) – elpadrinodk (a) gmail dot com.

        Specifically targeting vs2005 .. hmm, more or less. It seems that Google want to keep the project in vs2005 to make it as compatilible as possible.
        See the comment from Frank: http://groups.google.com/group/gdata-dotnet-client-library/browse_thread/thread/70c6638734823b8d/355abe0f7fa0ca0b?lnk=gst&q=analytics#355abe0f7fa0ca0b

        Looking forward to see what you come up with.

      • Alex M
        May 8, 2009 at 9:14 am | #7

        I just sent you an email with a zip attachment, let me know if there are any problems.

        Curious to hear what you think.

        Alex

  3. Paul
    December 2, 2009 at 4:21 pm | #8

    Hi

    Just came across this blog after doing a search for a .NET library that wrapped up the google analytics code

    First of all can I say, good job. I love it when fellow developers like yourself take the time to create code and make it available for others to use.

    Anyway, I downloaded the solution to give it a try, however I have not got VS 2005, I am currently working with VS 2008. When I am trying tp open the solution a pop up window asking we for a passwrd for signing pops up.

    Firstly, what is this key used for and secondly can you give me the password so I can open and build your solution properly and have a look round the code

    Thanks

    Paul

  4. May 19, 2010 at 10:44 am | #9

    Hi, I’m download Google library but I don’t find analytics reference… Where I can download it?

    Thanks
    Giuseppe

  1. No trackbacks yet.