Flash Google Analytics Tracking
If you’re anything like me, which I’m sure you are, then you really don’t like Flash components & SWCs either. They’re huge, cumbersome, and offer little to no introspection. If they don’t do exactly what you want out of the box, well, you’re pretty much screwed. There’s no taking them out of the box without a decompiler, and even then, who wants to maintain ugly decompiled code?
That’s my number one reason for avoiding Google’s Analytics SWC. Well, that and the enormous file size. I mean, tracking with Google Analytics isn’t rocket science. It’s not like Omniture tracking or anything (Stay tuned for the Omniture Tracking post). So why all the meat?
So you’re probably asking yourself, “Wait a minute. Is this going to turn into one of those rant posts that ends with him giving me a handy-dandy class that solves all the worlds problems?” Well, yes and no. I’m working on my WorldPeace.as class as we speak, but for now you’ll have to settle for a tracking class and helper.
All that Availability talk in the previous class probably got a little annoying. It’s really there to handle testing environment problems that I run across all the time stemming from ExternalInterface.available. That property doesn’t do the best job of telling the truth, and a lying property is about as useful as your rapper friend as a character witness. The following utility class patches some of the holes that ExternalInterface leaves gaping. If you don’t feel like using it, do a find and replace in the GA class and change “private static var _availability:Boolean = Availability.available;” to read: “private static var _availability:Boolean = ExternalInterface.available;“. You’ll need to fix the imports as well, but you’re an actionscript rockstar, so I don’t need to cover that.
As always, my code’s free to use and distribute. I don’t need a credit or shoutout or anything, though I always welcome comments and feedback. Find it useful, think of a better way to do things, have a bone to pick, feel I’m dissin’ your rapper homies, the comment box is below.