I want to have an onClick event on flashObjects to fire the google analytics event tracking for every click on Flash. What is the best way to accomplish this?
I don't have access to Flash source code that's why I want to do it with Javascript event.
edit: I found a workaround for this, don't know if its the right way though
<div onClick="_gaq.push(['_trackEvent','CommerceAd', 'IMAGE2000 Click', 'HomePage - Primary', 'sandybridge-horizon-banner']);">
<object type="application/x-shockwave-flash" data="/BannerImages/1103/sandybridge-horizon-banner.swf" width="98%" height="120">
<param name="movie" value="/BannerImages/1103/sandybridge-horizon-banner.swf"/>
<param name="flashvars" value="clickTAG=/some-url.html"/>
<param name="wmode" value="transparent" />
</object>
</div>
There is no need to use Javascript if you want Google Analytics within Flash. There is library for that:
http://code.google.com/intl/sk/apis/analytics/docs/tracking/flashTrackingIntro.html
I've done it many times using it and it works perfectly.
playGame.addEventListener( MouseEvent.CLICK, onButtonClick );
function onButtonClick( event:Event ):void
{
tracker.trackPageview( "/started-game");
//if user started game you'll see it as an access of subpage "/started-game" in your Analytics account
}