FGATracker for Google Analytics tracking

FGATracker is an AS3 library which wraps gaforflash for Google Analytics and can be easily used in combination with the Swiz framework.

Source and Download


Add FGATracker to your BeanLoader:

<ga:FGATracker id="fgaTracker"
	   account="GOOGLE ANALYTICS ID" xmlns:ga="com.soenkerohde.ga.*" />

Dispatch TrackPageEvent or TrackActionEvent:

From a view class (set bubbles=true):

dispatchEvent( new TrackPageEvent( TrackPageEvent.PAGE, "/pagename", true ) );
dispatchEvent( new TrackActionEvent( TrackActionEvent.ACTION "category", "action", "label", NaN, true ) );

From a non-view class:

_dispatcher.dispatchEvent( new TrackPageEvent( TrackPageEvent.PAGE, "/pagename" ) );

You can get a reference if your class implements the IDispatcherBean interface:

private var _dispatcher:IEventDispatcher;
public function set dispatcher(dispatcher:IEventDispatcher):void
	_dispatcher  = dispatcher;

2 comments to FGATracker for Google Analytics tracking

  • Margo Powell

    IdleTimer error message:
    When I started upgrading to swiz 1.0 last week, I had to modify FGATracker’s constructor and change the event in the event listener from FlexEvent.CREATION_COMPLETE to Event.ADDED_TO_STAGE. The GATracker instance apparently wants access to the stage and in my implementation my code was thowing an IdleTimer error for me, see the following link:


    Thanks so much for this library! It has made my programming life much easier and hopefully this note will help someone else that runs into the IdleTimer error message.

  • Thanks for the feedback. If you want to share your changes please fork the project on github so I can integrate them.