Skip to main content

Quick start: Add Google Analytics to your Adobe AIR application in 4 easy steps

I've been an advocate of Adobe AIR since I used the eBay "San Dimas" application (AIR was called Apollo, San Dimas became eBay Desktop). The potential to modern, build rich and smart client applications that have all the benefits of a web application (automated application updates) but the elegance and simplicity of a desktop application (native desktop integration) is a great option for developers who want to build modern client/server applications.
Recent developments by Salesforce (database), Amazon (email) and Google (XMPP) only strengthen the value of using AIR for rich client applications backed by cloud based Enterprise services. (AIR doesn't solve everything and modern browsers such as Chrome and Safari have comparable capabilities through their support for HTML5 ).

One of the downsides of using Adobe AIR, and Flash in general, has been the lack of support for Google Analytics. It was something that we severely lacked when we built the desktop gadgets at Oracle (for Siebel and CRM OnDemand). While we could track the downloads from the Oracle site, there was very little else that we could do (short of putting logic into the gadgets themselves to writeback to a web service) to track basic statistics such as how often a gadget was used, what features were used etc.
Lately I've been working with Adobe AIR for Android and have the same requirements for mobile application development.

The wait is over...
The recent addition of the AS3 library for Google analytics now enables any AIR/Flash developer to add Google analytics to their code and gain the same insight that web developers have enjoyed for years. And the other good news is, it is just as easy to add tracking to your mobile or desktop application as it is for a traditional web application.

Get up and running in 4 easy steps

1. Download the tracking library here

2. Add two import statements (tracking class, interface that the GATracker implements) and declare a tracking variable;;

public var tracker:AnalyticsTracker;

3. Initialise the tracking variable with your Google Analytics tracking token (replace "UA-123-4567" with your own token).

private function onComplete():void
tracker = new GATracker( this, "UA-123-4567", "AS3", false );

4. Start tracking.

public function onButtonClick():void
tracker.trackPageview( "/hello/world" );

In this example, every time a user clicks the button, a virtual pageview of "hello world" is sent to the Google Analytics tracking servers.

That's it, you're done!! Of course in your mobile or desktop application you don't have pages etc., but the great thing is that the mechanism is so flexible that you can choose to implement based on your own needs. I used the simple URL scheme to map specific modules and actions.

This post is just enough to get you started. If you want more information, the Google Project can be found in the Google Projects Labs section here.

Brilliant work by the folks who worked on this !! Many thanks !!


  1. Hi, I am trying to implement this to an air desktop project and can't make it work. I found the following statement in GA's site and now I am not sure if this will work.

    Currently, Flash tracking is available for any Flash content embedded in a web page. Tracking of data sent from Adobe Air, Shockwave, or via the Flash IDE (e.g. using Test Movie) is not supported at this time.

    Any thoughts would be very appreciated.

  2. It's been a while since I've used Adobe AIR so I couldn't comment on the status of the GA library.
    If you cannot find any open sourced hacks out there on github there are two possible work arounds

    1) use the Google Analytics REST API (you will have to use OAUTH2 to access the API) . I found a good post here:

    2) Adobe AIR could wrap JavaScript - so you could use the regular JS code that you post on web pages and embed that in your AIR project. However, I haven't used that feature since the the days when AIR was called Apollo so it might not be the best approach.


Post a Comment

Popular posts from this blog

How to get the BBC iPlayer running when you live outside of the UK

(subtext: Get the World's most famous detective on your favourite browser)

The new series of Sherlock has started on the BBC. If you live outside of the UK and you are too impatient to wait for your local TV content provider to host it for you - then fear not !! These simple instructions will get you up and running. In addition to the iPlayer you can access most of the other UK TV channels using the same method. Note: you can use the same method to access content in other countries - such as Hulu in the U.S.

How it works:  In simple terms, the BBC iPlayer, like other players, perform a check to determine whether your internet access is originating from the UK.  So the trick is to ensure that your access to the BBC website will originate from the UK.

First you are going to use a free piece of open source software that was designed to keep your internet access anonymous. You will add a setting that will ensure that the software makes use of servers in the UK whenever making requests…

Create an Alexa Skill for your Amazon Alexa or Echo Dot

So you've bought an Alexa Dot and you want to create your own voice app - but you are wondering how difficult is it to build, how do you build the app and how much will it cost to run?  If you have basic programming skills then building the application is really easy. If you have written a function or script in Microsoft Excel or Google Sheets - then you can build an Alexa voice app. I'm providing all the basic stuff you need to get started ...

Note: This post is not intended to give you an exhaustive guide to building a skill. Instead it aims to give you the overview to get up and running quickly. Amazon provides a build-it-yourself walkthrough (here), samples (here) and a free course on Udemy (here).  I recommend starting with the free course then following the walkthrough.

How much does it cost ? It costs nothing to build and run a simple Alexa app. $0 / £0 / €0.  Zero.  Furthermore the app is hosted on Amazon's cloud, it's secure, load balanced and managed for you …

Watch the BBC iPlayer and ITV Player when outside of the UK on Ubuntu

This is a follow up to my post of a year ago. The instructions are simpler than last year's post. If you want instructions for the Mac go here.

I re-imaged an old laptop last year with Ubuntu (12.04 LTS).  If you've never tried Ubuntu before, head over to  to try the latest version. The installation is straightforward and you can install it without affecting your Windows image (if that's what you're running). Not only is this fast (boots in seconds) it also has better support for a wider range of devices - specifically Wifi.

To run the BBC iPlayer on Ubuntu, do the following...

Step 1: Download tor from this site :  The download button should detect your operating system. For Linux the direct link is here. Alternatively you can use the command line and enter sudo apt-get install tor.

Step 2: Unpack the tor tar.gz file. Open the folder that was extracted. On my machine it's called 'tor-browser_en_US'.…