Google analytics in Flash / Flex

Last week I had to implement some google analytics in a flash application that I created for “artsen zonder grenzen“. I love the way that this can be done now directly from within the flash or flex application but I also noticed how crappy this api was written.

For instance (taken directly from the api):

“For example, if your object is called pageTracker, you would reference that object in your code as window.PageTracker.”

Make sure you use the same capatalized letters and not like in the example!

Second thing:

“In order for bridge mode to function correctly, ExternalInterface.avaliable must be set to true in your ActionScript 3 code. This also means that allowScriptAccess should be set to always in the HTML page that embeds the Flash content.”

First of all the “ExternalInterface.avaliable” should ofcoure be written differently, but I also regret the fact that this might suggest that ExternalInterface.available can be set in your as3 code while ExternalInterface.available is a readOnly property.

This is not intended to take a piss on google, I love what they do, but I think if you write an api it should be done thoroughly.

7 Comment(s)

  1. On Apr 7, 2009, zwetan said:

    and what about providing your comments in the google groups ?

    few things

    yes there is some lack of documentation, but that does not make the API itself “crappy”

    and yes sometimes it’s not the dev who write the documentation and so few things can be fuxored in the writing of the doc

    I personally can not edit this doc, but I ll point the personn that can to those little mistake, like y eah you’re making a big fuss about little mistakes in a documentation (which can always happen)

  2. On Apr 7, 2009, Gerben Robijn said:

    I didn’t say it was crappy…I said it was written crappy. The small thing I expect from an api is that these things are double checked so a user does not have to question this.

    Make it easy for your “customers” to use your products.

    I’m proud you consider my post as a big fuss, but it’s not intended this way. See it as a way to help to help the community for reading it right and help google with some pointers. Again no piss intended!

  3. On Apr 7, 2009, TJ Downes said:

    Hey Gerben

    i just wanted to point out that, after having used a number of Google APIs for ActionScript, Google seems to expect the end user to have a relatibely solid understanding of the ActionScript language or at least the ability to research the language to understand the terminology they use.

    To address your first issue, if I understand it properly: pageTracker is your internal variable, that you set. window.PageTracker is the property of the window object. It is not uncommon for the case of these to be different, especially since you are accessing Javascript. I see this more as a JavaScript API issue than I do a ActionScript issue because it seems the internal variable has good naming conventions.

    In regards to the ExternalInterface.available property, a little research will show you that this is unavailable to be set because it is dependent on the platform used. It is available if the Flash plugin is of type ActiveX or the NPRuntime is available to the Flash Player (in browsers such as Mozilla). Again, this is not a Google issue at all, rather you need to research ExternalInterface to see how these properties and methods work.

  4. On Apr 7, 2009, Gerben Robijn said:

    Hi TJ,

    Thanks for your comment.

    I agree that google can expect some knowledge from the reader.

    To begin with your second point: I know this information, but to increase usability of the api it should be better if they said something like “check if the platform supports externalinterface through the ExternalInterface.available property”

    The first point is documented wrong though. I in fact took it over just like it was described but it did not function. It should be “window.pageTracker” if the tracker on your html/javascript page is called “pageTracker”.

  5. On Apr 7, 2009, TJ Downes said:

    I can agree that the Google APIs, as most APIs, is poorly documented. Specifically, I find that either they do not go into depth about the situation (providing links to existing material would be fine), or they don’t give detailed examples on how specific functionality works. This is compounded by the fact that these APIs, even Google’s are closed source.

    I guess I have learned to live with “lite” documentation for so long I have come to live with it :)

  6. On Sep 9, 2009, alchemist said:

    Here’s a simple example using flex events to call GA API via ExternalInterface

  7. On Feb 3, 2010, Sharedtut said:

    I am a heavy as3 programmer and I wish google would have more support but is a blocked road. There is no much support at all.

Post a Comment