How to track clicks and events in Flash with Google Analytics

Bookmark this Google page and keep it around for reference. Tracking click-throughs in Flash with Google Analytics turned out to be easier than I thought. Use the following ActionScript to make your visitors’ clicks in Flash register with Google Analytics.

on (release) {
getURL("javascript:pageTracker._trackPageview('/path/to/page.php');");
_root.gotoAndPlay(3); //your action here
}

Of course, it’s the pageTracker._trackPageview() JavaScript function that’s really doing the work, so I assume you can call this function from within Flash wherever you can use the getURL() ActionScript function.

I am building a landing page for an online coupon campaign, and am using this code to track the number of downloads of the PDF coupon to compare to pageviews.

EDIT: Here’s another great post with a bunch of examples of tracking click throughs in Flash. Careful though, these examples are for use with the older Urchin Google Analytics JavaScript snippet.

Battle of the clickTAGs for Flash ad click throughs.

First, a bit of background.  Flash banner ads are usually click-able.  Because the publishing site (ie network TV sites, online newspapers, etc) usually uses a third party ad system to serve and track banner ads, the destination URL for any click through is not hard coded into the SWF (Flash ad).  It is dynamically injected into the ad at runtime with the use of a “clickTAG” parameter in the object HTML.  The ad system handles the pairing of the ad and its accompanying clickTAG URL.

I make a fair amount of Flash banner ads for Grady Britton clients.  I’ve noticed a an annoyance that should be easily solved.  At some point since the invention of the clickTAG, there was a division on the correct case of “tag” in “clickTAG”.  Some publishers require that the variable name be “clickTag”, and others insist that it be named “clickTAG”.

Why does this matter?  It turns out that some of the third party ad systems are case sensitive when it comes to the use of clickTAG.  For me, that translates into creating 2 versions of every ad, one who’s code respects “clickTag”, and the other for “clickTAG”.

image of Adobe recommended clickTAG ActionScriptSure, I could write a simple switch to test which version exists and set accordingly, but the publishers employ QA folks armed with Flash decompilers. If the ActionScript that the decompiler reveals (which by the way, is rarely the actual ActionScript as written by the designer) does not exactly match the structure as required by QA, they won’t run the ad, regardless of whether or not it will work.

So, if the ad serving companies aren’t going to stick to “clickTAG” as recommended by Adobe, then let us designer/developers switch and validate the parameter without QA throwing up red flags because the ActionScript doesn’t look the same as the reference manual.  Creating one off versions of the ads to deal a basic case sensitivity issue is just silly, especially if it can be solved for all future projects with a few lines of ActionScript.

Related Posts Plugin for WordPress, Blogger...