Building your apps

Using Google Analytics with Adobe AIR install badge

Adobe AIR install Badge exampleIf you're developing Adobe AIR applications you might use the AIR install badge on your site to allow easy downloading of your application. So how can you integrate Google Analytics to track how many times your application has been downloaded? It's easier than you think...

These steps presume you're already familiar with creating an Adobe AIR install badge and Google Analytics is already installed on your site.

Integrate Google Analytics into your AIR install badge:

  1. make sure you have the latest Adobe AIR install badge files (download zip from Adobe site)
  2. Open the file ""
  3. Add the ExternalInterface class somewhere under the other import statements (top of file) import flash.external.ExternalInterface;
  4. then find the method "handleActionClick" and add these lines as first lines within the function: // GoogleAnalytics script // change the gaLogAction value to the name you want to appear in the Analytics logs var gaLogAction:String = "/airbadge/"+action; var gaJS:String = "pageTracker._trackPageview";, gaLogAction);
  5. open the file "AIRInstallBadge.fla" to recompile your badge with the changes you just made
  6. upload the newly created AIRInstallBadge.swf to the same location on your site, overwriting the old AIRInstallBadge.swf
  7. test if the new clicks get registered in the Google Analytics site (this might take some time to show in the statistics, so be sure to check the next day as well)
...that's all there is to it

Some notes however:

  • this is the workflow for the newest Google Analytics script (ga.js, not the older urchin.js) you have to change the value in variable gaJS for the older script.
  • Your site should have Google Analytics installed already, if not please check out the Google Analytics site for more info.
  • And maybe an unnecessary note, but I make it nonetheless: the badge uses Actionscript 3.0 and at least Flash 9