Adding Google Analytics tracking to your cairngorm flex or Air applications is really simple.
I will assume you are familiar with Cairngorm and already have an analytics account.
1. Download the analytics swc file and add it to the libs folder of your application.
2. Open you model/modelLocator file and add a public AnalyticTracker variable:
public var tracker:AnalyticsTracker;
In your main application file, inside a creation complete function add the following code:
public function onCreationComplete():void { //dostuff // add you account number where the XXX's are model.tracker = new GATracker(this.appManager,"XXX-XXX-XXX","AS3",false); //do other stuff }
Then you can track any event you like using the model.tracker.trackPageview command
public function execute(event:CairngormEvent):void { model.tracker.trackPageview( "/AIRapp/sampleEventExecuted" ); //do other stuff }
This will then keep track of how many times this event is executed via google analytics. You can use google analytics setting to filter your data into more meaningful information.
I would imagine this would not handle tracking of events when an air app is used offline but it does not throw any errors I am aware of if you do happen to be offline.
|