SWFTrack™ - Tracking hits on all-Flash sites

Judging by the response that I got just by accidentally posting the spot’s title on the site a day or two ago, there’s some curiosity as to what I’ve got in store.

In the interest of open source creativity I present to you a little something simple I cooked up… SWFTrack™.

A problem that many who develop all-Flash web sites face is that of not necessarily being able to effectively track where users are going within your site. I was wanting to see where people were looking on my portfolio site while keeping the whole site in one Flash presentation, thereby keeping that stateless appearance.

I started researching ways to track clicks through Flash sites, and found that there really was not a whole lot out there in terms of solutions. So, I set out to develop one myself. The solution itself is very simple and leverages Flash and the fundamentals of AJAX.

To begin, your site must utilize frames. Set one frame row to a height of zero pixels and the other 100%. Name the zero height frame “swftrack” and the other something else. The code would look something like the code for jeremyfuksa.com:

<html>
<head>
<title>Jeremy Fuksa :: Creative Generalist :: Portfolio</title>
</head>
<frameset rows="0,*" border="0" framespacing="0" frameborder="0">
<frame xsrc="" mce_src=""   name="swftrack" scrolling="no">
<frame xsrc="main.php" mce_src="main.php"   name="main">
</frameset>
</html>

The Flash part of it is also very simple. In any button code that you have in your Flash presentation, simply add this code:

on (release) {
// whatever other button code you have written
getURL("swftrack.php?sectionClick=MySection","swftrack");
}

“So, what’s in this swftrack.php?” you ask? Well… this:

<?php
// Customize $pageTitle to read however
// you want the page title to register in your
// tracking application. (i.e. Mint)
if ($_GET[‘sectionClick’] == “”) {
$pageTitle = “Portfolio :: Main”;
} else {
$pageTitle = “Portfolio :: “.$_GET[‘sectionClick’];
}
?>
<!DOCTYPE html PUBLIC ”-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html;
charset=ISO-8859-1” />
<title><?php echo $pageTitle; ?></title>
</head>
<body>

</body>
</html>

Doing this gives you a dynamically titled page that gets injected into your tracking software. Here’s what it looks like in my Mint installation:

Image missing.

“Tiki Bar :: Characters” and “Tiki Bar :: Cast Listing” are buttons within my Flash presentation at tikibarcartoon.com that call SWFTrack. Now, instead of just getting a set amount of hits to that site, I can segment and see who is hitting what within that Flash site.

Yes, it’s simplistic, and yes, there could be better ways to do it, and that’s one of the main reasons I share this with you now. As part of the open source aspect of this, I invite you to improve upon it and share your findings with the rest of the world. Here are some features I am adding to SWFTrack 2.0:

  • Ways to make swftrack.php present indexable content to search engine spiders while making direct human hits to the file redirect to the home page with the correct desired site state. Huh? Well, let’s say that if you were to click a link in Google that took you to www.jeremyfuksa.com/print, you would immediately be taken to the print section of my Flash presentation, not to the home page. If you were a search bot, you’d get a text only version of whatever was in that Flash section.
  • Inventing ways to make the solution a little more elegant. But, who knows, maybe the solution’s charm and usefulness is in its simplicity and “why didn’t I think of that?” factor.

Enjoy, and please, let me know if you use or improve this solution!


About this entry