01 feb 2009
Using Google Analytics with Adobe AIR install badge
If 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:
- make sure you have the latest Adobe AIR install badge files (download zip from Adobe site)
- Open the file "AIRInstallBadge.as"
- Add the ExternalInterface class somewhere under the other import statements (top of file)
- 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"; ExternalInterface.call(gaJS, gaLogAction);
- open the file "AIRInstallBadge.fla" to recompile your badge with the changes you just made
- upload the newly created AIRInstallBadge.swf to the same location on your site, overwriting the old AIRInstallBadge.swf
- 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)
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