Adding Google Analytics to your cairngorm app

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.

 

Comments
Add New
Powered by !JoomlaComment 3.26

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Help my beer fund

RocketTheme Joomla Templates