Recently I have found myself building projects that attach itself to Google Analytics. Google has their own class, but I found it quite big and unnecessary. I’ve decided to build a class where you can pass in what you want to be displayed in Google Analytics and the class would make the call to Google with the corresponding information. Just like Google.
Now this code requires you to have a Google Analytics account setup (its free : ) – link: http://www.google.com/analytics/ ). When you create a profile, you will be given javascript code that would be placed inside the html file. Make sure you have the tracking code before the bottom tag, otherwise the code would not be executed.
That is all with the HTML. Now in your flash file, you would need to import the Google Analytics class
import analytics.GoogleAnalytics;
From here on end, it is up to you what and where you want Google Analytics to track (i.e mouse events, load events etc.).
Whenever an event occurs all you need to do is call the trackAnalytics function. Pass in what you call this event, and that’s it, google can track your actions.
Ex:
GoogleAnalytics.trackAnalytics( "MyEvent" );
File can be downloaded here: http://www.josh-ho.com/blog/Files/GoogleAnalytics.zip