More about Google Analytics for Flash

I know I have been bad mouthing (see comments) a bit on Google Analytics for Flash, but it is mostly because I expect great things from that library and I have been wanting it for a long time. Last week I have been playing around with the API and there is a couple of findings I wanted to share with you.

First off, the library only works for Actionscript 3, which is not a big concern to me because I hope I will only be doing Actionscript 3 projects from now on. Also, when you include the library (at least in AS3 mode, haven’t tested in bridge mode) it will add about 40k to your file size. This is not so bad, but not so good at the same time. Making this smaller could make it accessible for a broader range of projects. Also I tried to import both the SWC you find on the download from Google code, but none of them would work; Flash would complain about not being able to import them. I finally circumvented that problem by checking out the source code using SVN.

Once you’re set up, one off the coolest things you can do is set the tracker to debug mode; it gives you some insights about what is going on under the hood. But for those of you who don’t want to go through all that trouble I just posted it down here:

Here is the Actionscript 3 code I used to make my test:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;
 
var tracker:AnalyticsTracker;
 
tracker = new GATracker( this, "UA-639032-8", "AS3", true );
 
button1.buttonMode = true;
button2.buttonMode = true;
 
button1.addEventListener(MouseEvent.MOUSE_DOWN, _onBut1Down, false, 0, true);
button2.addEventListener(MouseEvent.MOUSE_DOWN, _onBut2Down, false, 0, true);
 
function _onBut1Down(event:MouseEvent):void{
	tracker.trackPageview("/test1");
}
 
function _onBut2Down(event:MouseEvent):void{
	tracker.trackEvent( "say", "hello world", "test", 123 );
}

In this code, the fourth parameter in the constructor of the GATracker object is the debug parameters, setting it to true will enable this view.

My main goal for making this was because I had read that in AS3 mode you could track events yet (check in the comments). So I created a new profile in my GA account for testing purpose and set all this up, but the major problem was that not all profile get event tracking activated.  Actually, I have written a post about event tracking being out, but my guess is that Google is extending the beta (Google sure does love betas) to more accounts and that mine was one of them. But even if your account has been activated for event tracking, newly created profiles won’t be activated.

So I had some test running but no way to check the results. That was true until I found this hidden gem (I am probably shooting myself in the foot right now and should keep this a secret but hey!) in the midst of the Google code website for Google Analytics for Flash : A request form to activate event tracking on certain profile of a Google Analytics account. I did so, and three days later I could see the results of my tests. Event tracking was working just fine in AS3 mode. The form says that they will accept 500 requests so you better get profiles activated if you plan on using it. But even if your account is not activated Google will still record the events; it’s just that you won’t be able to see the results until it is activated. We have some projects that fall in that category; mostly the Twist Image Holiday card : It’s a wonderful life (shameless plug). We hope event tracking gets out of beta really soon!

Well that’s about it, see you tomorrow as I try to complete this week of post every day.

, , , , ,

  1. #1 by fredo - August 23rd, 2009 at 18:20

    40k for GA tracking? Ouch! What’s the alternative to using the SWC?

  2. #2 by sawrb - March 29th, 2010 at 07:31

    Yea, I’ve been struggling with the 40k SWC too. Can’t afford to pile on 40k in my flash widget (It is hosted on a high traffic site). The other way round is to check in the GA code and try and weed out anything that is non-essential. But I have just begun, down that road. Not sure where its headed. Any pointers, @zedia?

(will not be published)
Subscribe to comments feed
  1. No trackbacks yet.