Best Practices - Tracking Flash Files
August 20, 2007 – 8:49 am
There’s often a lot of confusion when it comes to understanding where to even start when tracking a site that’s essentially only a Flash movie so this post will try to clear some of that up. I’ll make the assumption here that your data collection method will be client-side / browser-based (Google Analytics, WebTrends SDC / OnDemand, Coremetrics, Omniture, etc.) but try to keep the conversation as vendor-independent as possible however I will likely use Google Analytics for examples.
First things first, remember that when using pieces of software that only know how to track page views and visits and visitors, tagging and tracking a Flash movie is essentially no different than tracking any one of your pages, it’s just that it requires a bit more manual intervention.
Just to cover my butt here before I get yelled at, Coremetrics and Omniture are starting to get clever in terms of tracking things like “events” as opposed to the standard three metrics, but I’ll leave it for your account people to talk to those points.
The next thing you need to know is the method for which you’ll be collecting data - while this may not be as important to you, it will be very important for your web developer to know. Flash contains a function named getURL which allows the Adobe Flash Player to change the location of the browser, but also, getURL can be used to execute JavaScript on pages. As you may or may not know, all client-side web analytics applications use a tiny bit of JavaScript embedded in each page to grab all data and send it off to the data collection servers. So then with Flash’s getURL, we can “simulate” page views by making calls to the functions our analytics applications expose to us.
Before we go any further just remember, the rule of thumb for Flash movies is you’re going to either be tracking “Flash page views” or “Flash events as page views” - there’s literally nothing else so don’t over complicate things.
Also, let’s use a working example to help us out a bit and refer to Stella Hernandez’s personal photography site (which by the way is using Google Analytics right now!).
Tracking Flash Page Views
This mindset tends to apply more to sites that actually use a Flash movie as either the entire site itself, or an embedded mini-site within.
Think of a Flash page view in the same way you would think of any other page view on a site. When you load your homepage you expect to see a page view for the homepage. When you click one of your navigational links, say to the contact us page, you expect to see a page view for the contact us page. In a Flash movie, things are no different.
Step one of tagging your Flash movie is to map out what in your Flash movie constitutes a page view. Taking Stella’s site as an example, when her site loads, we get a nice intro Flash movie loading and then it’s onto the main site with navigation. If I were tagging this site, I’d evaluate where we are in the movie so far as one page view - the homepage. Sure there was a bunch of funky animation going on, but what’s important is that I didn’t actually do anything in order to get to the next “page”, I was just brought there.
In order to grab this one page view, simply add the analytics tracking code to the HTML page that hosts your main flash file and presto, we’ll get a page view for the homepage. We’re not doing anything to the Flash movie itself yet, just having the tracking code on this page gives us the initial information we need. Having the tracking code embedded on this page also will allow us to do all the subsequent tracking that we need to accomplish for the entire Flash movie.
Next let’s examine this “homepage” a bit more. From the looks of the homepage we really only have four top-level pages to the whole site:
- Collection
- Friends and Clients
- Tearsheets
- Contact
Although I’m not sure how the Flash movie was written, let’s assume that every time I click one of those links I’m actually requesting a new movie (although to the end user it looks like one smooth experience). Following that logic then, when I click the “Collection” link and load the new movie I want to track a page view. If this site weren’t a Flash movie, then I’d expect this to be a page viewed, right? So when the movie loads then we make a little call inside the movie and just for example’s sake, let’s pretend we’re all using Google Analytics:
getURL( "javascript:urchinTracker('/collection/');" );
You’ll have to work with your vendor to establish the exact code to add inside the getURL() part.
But with Google Analytics, we’ve successfully just created a page view for the homepage of the /collection/ directory. You might be thinking, “Hang on…there is no /collection/ directory” and you would be absolutely right. For Flash movies, we don’t care that there is no physical directory named /collection/ on the web server, we’re just interested in grabbing the user’s activity and we successfully accomplish that with this method.
With that little line of code, you’ll now get all the information you ordinarily would from any other page on your site. Information like: total page views, total visits (unique page views), time on page, exit rate and bounce rate (single-page visits). It’s that easy!
Let’s continue this example to the images contained on the collections page. If I were Stella, I’d be very curious to know things like:
- What are my top 10 photos on the site?
- How long are people viewing my photos?
- How many photos do people view on average?
The good news is all of these questions can be translated into commonly answered questions by web analytics applications:
- What are my top 10 photos on the site? - Content report of the top 10 photos with highest page views or highest visits (unique page views)
- How long are people viewing my photos? - Average time on page for all photo pages
- How many photos do people view on average? - page views per visit for just the photo section of pages
So following our first example, say we add a little piece of code so that when any image loads (I’m assuming the code for image loading is probably shared for all images), we make a little call with our handy getURL that looks something like this:
getURL( "javascript:urchinTracker('/collection/imagename.jpg');" );
With just this bit of code (substituting imagename.jpg for the actual image file name) added to all images for this section, we’re now able to answer all the questions above and more!
For the rest of the Flash “pages” on the site the same methodology applies, just keep these things in mind:
- Page views as you’d normally consider them are no different from page views as you’d consider them in a flash file - they just take a bit more manual intervention
- When choosing the fake “location” of your page view (i.e. /collection/), name the location however you’d like, but just make sure it’s something that clearly makes sense to the business owners of the data afterwards. In other words, make sure that your programming team doesn’t decide to come up with their own cryptic naming convention on your behalf
- getURL will quickly become your best friend on a site that’s fully Flash enabled
Tracking Flash Events (as page views)
Many Flash movies contain “events” that aren’t really considered page views in the traditional sense. For example, on Stella’s site, she has the controls for the music player at the top of the page where I can stop or play the music for the site. Now ordinarily we wouldn’t think of pressing the stop button as a page view because the content on the page I was looking at didn’t change at all, but to most analytics applications, everything has to be considered a page view (see my note above about the clever innovations that Omniture and Coremetrics are starting to make).
The good news about this is that if everything is a page view, then the method that we used to track “traditional” Flash page views above, is the exact same method we employ to track Flash events.
Using those stop and play buttons as a perfect example, in order to answer the question: “How many people seem to be annoyed with my music and just turn it off?”, we simply need to track the stop button of the music control and report back how many visits out of our total site visits press stop.
On the stop button then, the code we might add to the “onClick” event (for you web developers out there) might be:
getURL( "javascript:urchinTracker('/music_controls/stop_button_pressed');" );
Similar to above, we know there’s no page at /music_controls/stop_button_pressed/, but that doesn’t matter. All we want to know is that there was activity around this stop button. Once this tracking is in place, we’re instantly able to know how many visits out of the total visits to the site are clicking the stop button. While some may click it for fun, if 80% of visits click stop, it’s pretty safe to say Stella may be annoying some of her audience.
To Summarize…
Tracking Flash movies with client-side methods is nothing to be afraid of. As I hope I’ve shown above, if you think of everything in your movie divided between either a Flash “page view” or “event”, then you’re set to understanding how to track these actions.
From there, you’ll just have to be a bit creative to get the types of answers you’re looking for (i.e. “Is my music annoying people on the site?”).
Hope this sheds a little bit of light for everyone out there!

21 Responses to “Best Practices - Tracking Flash Files”
Great overview, especially for someone who hasn’t done any of that before.
Couple of points:
Might want to clarify the whole “Data collection will be client side” bit. When I visit a site I’m not collecting anything. I’m triggering events that get tracked by a company that’s doing the hosting (well, for on demand services anyway). When I see client side I see that as something the users are doing, and they’re definitely not collecting data.
Pieces of software sounds so demeaning to them. They’re analytics tools!
As far as clicking tracking goes, I believe in flash you want to use on(release), not on click, but I could be wrong since I’m not the developer these days.
One cool thing about more sophisticated tools like WebTrends is that you can make the flash event way more useful than Google seems to allow. I’ve had apps that fire the “page view” along with a whole string of custom variables, which is really cool for building reports, especially when you want to keep some of that data for future segmentation.
By Bryan C on Aug 21, 2007
In response to Bryan C’s post - First of all thanks for reading Bryan!
Believe it or not you’re the second person to warn me that I may be assuming too much with my audience to guess that everyone is aware of what “client-side data collection” is all about. It’s great feedback to get and important for me to remember.
What I was referring to by “client-side data collection” in this post however was use of browser-based (i.e. JavaScript) tagging to capture user activity. This is what most of the industry has moved towards and is what Google Analytics utilizes.
“Pieces of software” may have been a bit harsh…but we all get frustrated with these “analytics tools” once in awhile!
Towards your Flash comments, I actually didn’t want to get to specific with onClicks or onRelease mentions as I don’t want people thinking they have to rewrite their code. I’m hoping the post did a good idea of laying out the framework as well as providing a bit in the way of example.
You’re absolutely right on with your comments about WebTrends custom parameters that can be sent - they’re very VERY handy. One of the trickiest things about Google lacking this kind of ability is that building a profile for a sub-category of content becomes a lot harder when tracking all of my events. What if I track all of my events under /events/, but am trying to build a profile for my sports content (under /sports/) for my site? I want to include all that click data surrounding /sports/, but it’ll be tough to pull it out unless I’m appending query string parameters to the events.
In WebTrends however, I can setup a quick DCSext variable and I’m off to the races!
Thanks very much for posting!
By mike.sukmanowsky on Aug 21, 2007
I want to track a movie clip loading into the root movie. Would I place this script in the first frame of the movie clip I want to track?
onLoad = function() {
getURL( “javascript:urchinTracker(’/clients/arm_w_logos’);” );
}
I’m using Google analytics.
Thank you.
By Justin on Sep 17, 2007
In response to Justin’s post - Hi Justin, thanks for posting a question! What you’ve proposed above should work just fine. As I’ve tried to convey in the post, you can put a call to urchinTracker anywhere you think makes sense in the movie (following the best practices above). You may want to use something a bit more descriptive than ‘clients/arm_w_logos/’. If this makes sense to both you and your clients then great! But make sure you don’t have to do an awful lot of translating on your own for them to understand what ‘arm_w_logos’ actually means.
Best regards,
Mike
By mike.sukmanowsky on Sep 17, 2007
Mike,
I really appreciate you taking the time to answer my question, and creating such an informative tutorial. All of your comments have helped me.
Thanks,
By Justin on Sep 18, 2007
I understand that this is not the same thing at all, but it is still slightly related. Is it possible to use similar approach to trigger Internet Explorer events? I am using an Add-On that logs page my visits and would like to be able to log Flash “page visits” as well. Can this be done?
By Joakim Isaksson on Oct 1, 2007
In response to Joakim’s post - Hi Joakim, I’m not sure I completely understand what you’re asking…for something like an ActiveX plugin to track pageviews and what not that plugin would have to be able to execute JavaScript calls within the browser. So I guess so long as you have a way to do that with your Add-On then you’re set!
Hope that helps somewhat.
Cheers,
Mike
By mike.sukmanowsky on Oct 1, 2007
hi,i was wondering
do you know of any server-side tracking applikations that can handle flash?
best regards
mads
By mads tagel on Oct 2, 2007
In response to Mads post - It’d be very difficult if not impossible to create a server-side tracking application for Flash only from the standpoint of the only interaction that a server has with a flash movie is when the movie is downloaded. All subsequent interactions in the movie are client-side only. You could write stuff into the Flash movie to talk to your server, but then you’re basically doing the exact same type of thing I’ve recommended above. Sorry Mads!
Thank you for posting!
By mike.sukmanowsky on Oct 2, 2007
So it’s as easy as just dropping
getURL”javascript:urchinTracker ‘/example/’);” );
into the flash file:-).
Dumb question?
In one of the posts above, included in the code is onLoad = function() {. What is this code and do I need it if I just want to track flash “page views.”
By brian on Oct 22, 2007
In response to Brian’s post…
Thanks for writing Brian, you don’t *need* an onLoad() function, I was simply referring to it in the event that your code looked similar. The idea behind that example is generally in a full flash site you probably have separate movies in one main .fla file. Each movie has an onLoad() function so when a movie loads, you generate a page view for it.
Does that kind of make sense?
By mike.sukmanowsky on Oct 22, 2007
Yeah, I think so.
I’m trying to help a friend out with a Google analytics setup for his site. Unfortunately for me, the site is all flash, which I didn’t realize when I agreed to help.
I’m not exactly sure how the flash movie is structured, but visually, it’s almost identical to the example site you use above. He’s looking to track “page views” for the 5 links on the homepage.
I’m kind of at a loss since I’m not a developer, but I’m trying to figure this out on the fly. I want to learn and understand how GA works for flash, it’s just not easy when you don’t know much or anything about action script. Please help:-)
By brian on Oct 22, 2007
Doh! I just realized by reading your tute that everything I read about using GA to track clicks on Flash buttons pertained to using getURL for internal files not for loading another web page into self or a new browser window.
I am seeking to track one or more Flash buttons that use getURL for external files. Please tell me someone has figured out a way to count these clicks and identify which button was clicked.
By somnamblst on Dec 14, 2007
In response to somnamblst’s comment…
If I’ve understood everything that you’re asking correctly, then tracking one or more Flash buttons follows the same premise as tracking any other event in your Flash movie. Simply adding a getURL call to those buttons and specifying specific values for the urchinTracker call will enable tracking.
I would encourage you beforehand however to evaluate if tracking the clicks to these two buttons is absolutely necessary and provides you with information that you’ll be able to act upon immediately.
Happy tagging!
Mike
By mike.sukmanowsky on Dec 16, 2007
Everything that is talked about involves creating page views that represent events. This is fine, but it does inflate your page views for summary data, doesn’t it?
We are using wt ondemand, and want to track some ajax delivered content (basically want to track the presentation of certain links as impressions), but there could be as many as 5 per page. This would add as many as 5 extra page views to the top line page view stats, or at least one extra page view if we send this impression data as a parameterized list on a single page view.
Is there some other technique that I may be missing? The call for the ajax portion has to be handled separately from the main page tracking due to page rendering order etc.
-any thoughts are appreciated!
By kevin on Dec 21, 2007
In response to Kevin’s post…
You raise a very good point! Tracking everything with a page view is not a very good way to go about things but unfortunately when last I checked, WebTrends SDC / OnDemand doesn’t offer anything outside of pageviews for the most elementary metric.
Other tools (Omniture, Coremetrics, Google Analytics) actually offer non-pageview tracking for this exact concept.
It has been awhile since I’ve played around with WebTrends, so first thing’s first I recommend getting in touch with your account rep and asking them to read this post and give their take on it. They may have developed something new.
In the event they haven’t, I’d recommend adding a query string parameter to all your non pageview calls (something like /flashplayer/playbutton?nonpageview). At least this way, you’ll be able to set up filters to remove that activity from your regular profiles and even add them to their own profile.
Happy tagging!
Mike
By mike.sukmanowsky on Dec 24, 2007
Great tutorial Mike.
Thanks a lot. I was wondering if you can recommend a similar sight for Microsoft Windows Media files.
By Rahul Kapoor on Jun 1, 2008
In response to Rahul Kapoor’s comment…
Thanks for reading Rahul - I don’t know of a site that has specific information about Microsoft Windows Media files. Actually I think you’ll find you may have trouble tracking a Windows Media player. As I understand it you can’t edit / modify any of the code for that particular plug-in.
Best,
Mike
By mike.sukmanowsky on Jun 1, 2008
Hi Mike,
That’s a nice article very informative. But i have somewhat tweaked requirement here. I want to collect analytics for my embedded flash file in the other websites around the world. i.e. I know this is not feasible through _root.getURL method as that will always point to the location where it is being picked up, which in this case is the website which is providing the flash player to be embedded in personal blogs or websites with embed code.
But i have seen quite a few sites which does provide anyalytics for the embedded content on different sites and number of hits they are receiving. So i believe it’s the request or something like that which is being sent through the flash file to originating website and requested page parse the request header to know the pinging website. Any idea regarding this?
By Vivek Lakhanpal on Jun 6, 2008
I found the solution to the above mentioned problem. You can check that at http://viveklakhanpal.wordpress.com/2008/06/11/picking-up-the-domain-name-where-your-flash-fileplayer-has-been-hosted/
Thanks,
Vivek
By Vivek Lakhanpal on Jun 16, 2008