Web developers are using Google's free web based Google Analytics tracking tool to generate reports about a site's performance and use by visitors. Tracking standard XHMTL pages involves, by the simplest method, dropping some code, generated by Google Analytics, just before the closing body element of each page. When users navigate to different pages, this code is parsed by the browser and communicates the visit to the tracking database.
Some sites are delivered in both a Flash and XHTML (or Flash only, though this is not recommended), letting the user(s) choose which version they prefer. A Flash site typically sits in a single XHTML page. Navigation within the Flash movie doesn't link to external pages (though it may link to external Flash movies) but rather to other locations along the timeline of the Flash movie itself. It would be useful to be able to track how users are navigating the Flash version of a site in order to improve the site's function. Fortunately, Google Analytics makes this possible. Let's take a look at how it's done.
Flash movies are referenced within a standard XHTML page. Before we look at tracking Flash navigation specifically, let's look at how Google Analytics works with a regular XHTML page and how we use the same method, with an important difference, as the first step in tracking a Flash movie.
After you've created an account and added a site for tracking in Google Analytics, a unique account ID number will be generated and placed with a block of code that you should place just before the closing body tag of each of your XHTML pages (the account code is fake in the following example.)
<!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>
head content here
</head>
<body>
body content here
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-xxxxx-y";
urchinTracker();
</script>
</body>
</html>
Having placed the code in each page on your site, you'll have to upload the changes. Give it a few days and you can view the tracking results.
You will be using this same block of code when tracking yoru Flash movie. However, there is one key difference. Let's take a look at it.
When tracking Flash movies, the first step is to place the same block of code we use in standard XHTML sites just after the opening body tag rather than just before the closing body tag as we normally do. After that, you include your regular Flash code. In my case, I'm using Geoff Stearns excellent SWFObject method for implementing Flash as I find it much better than every other method, including Adobe's. Visit http://blog.deconcept.com/swfobject/ for more information.
After you've created an account and added a site for tracking in Google Analytics, a unique account ID number will be generated and placed with a block of code that you should place just before the closing body tag of each of your XHTML pages (the account code is fake in the following example.)
<!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>
head content here
</head>
<body>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-xxxxx-y";
urchinTracker();
</script>
<!-- Flash Code: Start -->
<div id="flashcontent">
Alternate to Flash content goes here
</div>
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("/flash/flashmovie.swf", "Flash", "950", "600", "8", "#FFFFFF");
so.write("flashcontent");
// ]]>
</script>
<!-- Flash Code: End -->
</body>
</html>
That's all you have to do for the XHTML page that references your Flash movie. The next step, takes place within Flash itself.
To track where people are going within our Flash Movie we can use the getURL function to use the tracking Javascript code that we've placed in the page that references our Flash movie. We place it inside of a button event. For example, if we want to track if people are clicking an 'About Us' button in the Flash movie we could use the following code.
b_about.onRelease = function() {
getURL("javascript:urchinTracker('/flash/about');");
_root.gotoAndStop("about");
}
In the example above, I've used /flash/about as the tracking variable that I'll see when viewing content perfomance and navigational analysis (as well as other options if you wish) in a Google Analytics report. This tells me first, that the event being tracked is within Flash, and second, that the about section was viewed. You can include this function for all of your buttons as needed.
For more information visit the Google Analytics help page.
discuss this topic to forum
