Google Analytics straight up Flexified

I woke up a couple of days ago to a torrent of blog postings on MXNA all talking about the help page found on Google’s Analytics site stating that Flash events can be dispatched to Analytics through the getURL method. I figured a working example could be made pretty quickly, and in very few lines of code. So here it is, as always source is available through the right click menu.

http://www.chrisrebstock.com/stuff/google_analytics_flex-ified/

Its only a few lines of code, I utilized a static dispatch and event storage system. As I remember reading in one of Jesse Warden’s posts, static is the new global! I started by making an interface, which didn’t feel quite right, I then made a class to be extended by view elements that wanted to be tracked, which didn’t feel very natural either. I figured both solutions would be overly complicated for large scale deployments with lots of events being tracked, and the lack of centralization would mean that you would be tracking down each event individually. So the old static function and static event strings seems to be the best way to go. No matter how many events you have, you’ll only ever have a single dispatch class and some class(es) to store your static event strings.

Here is a screenshot showing a pie chart version of Google Analytics displaying events from the Flex App. Here is another screenshot showing a content list view of the events.

Generally, this looks like a decent (and free) way to measure flash statistics. The layout is clearly not designed for flash (or even AJAX) content though, as the whole pageviews thing is pretty silly in the dynamic context. Many technologists have been clamoring for an analytics API, since the current analytics page is clearly not designed for dynamic sites. If Google did release an API some of the flex wizards in this community could make incredible tracking systems using Flex’s charting components. The combination of those charting components with data services could provide real time tracking, although that wouldn’t work with Google’s analytics since it updates only every 24 hours.

Which segways nicely into my next thought, that Google Analytics is about to face some serious competition, which is based off of a couple of predictions. First, Google will not provide an API to Analytics. Their deprication of a previous API serves notice that Google’s main intention is to turn revenue from AdWords and they will not support any initiative which does not directly or indirectly further that mission. Since an API is a way for other developers to hook into their infrastructure with their own front ends (and obviously without Google’s ads present), they are likely to see that as a direct threat. Second, the concept of updating stats every 24 hours will not be acceptable for many tracking needs. As competition increases, so does accountability, and as accountability increases, so will the expectations for measurable and actionable data. Getting your data once a day may be ok for the next year or two, but it won’t be for much longer than that. To many users, seeing data on their latest initiatives will become just as crucial as checking their mail or RSS feeds, and I don’t think anyone would agree nowadays that its acceptable to get their email once a day at 12:00AM.

4 Responses to “Google Analytics straight up Flexified”

  1. prasanth  on November 25th, 2007

    hi,

    thank u very much for ur sample, i have taked ur sample code and try to run in my application, it runs fine but google analytics doesnt record my events, is there any thing more i have to do.

    i have included my ga code in the html also.

    adv thanks
    prasanth

  2. crebstock  on November 26th, 2007

    Since you’re basically just sending a page view event to Google Analytics, I would say its most likely that your problem is with analytics itself. Have you tested to make sure you’re even getting the base page view event if you’re not getting the flash events? Since the flash is just sending specific page view events, its most likely true that analytics isn’t working for your page at all, not just the flash part. Check to see if you’re getting any readings from the page at all, Analytics will tell you if it is successfully getting page views from the URL you set up.

  3. Raj  on September 9th, 2008

    Your sample page does not work with FF 3 and Flash Player 9. I get the following error in the console:
    SecurityError: Error #2169: The method sendToURL may not be used for browser scripting. The URL javascript:urchinTracker(’/trackButtonAEvent/’); requested by http://www.chrisrebstock.com/stuff/google_analytics_flex-ified/GoogleAnalytics.swf is being ignored. If you intend to call browser script, use navigateToURL instead.
    at global/flash.net::sendToURL()
    at com.chrisrebstock.analytics::Tracker$/sendTrackEvent()
    at GoogleAnalytics/btnAClick()
    at GoogleAnalytics/___Button1_click()


Leave a Reply