MP3 site Music shop Billy Talent Carcass Bjork Pitbull MP3 search Ozzy Osbourne Music database Steve Perry Pink Floyd

Tracking Time : Brightcove with GAForFlash Event Tracking

brightcove-and-google

When your business is making money based on time then tracking time is of obvious importance. With a little Flash wizardry and the GAforFlash tracking classes you can easily accomplish this task.

In our tests the 3 important metrics to test against were:

1) Player load time
2) Amount of time it takes for the first video to play
3) Duration player was being viewed (5 and then 10 second interval )

To get the player load time and then the video playing time we first grab the current time when the swf initially loads:

[as]
startTime = new Date().time;
[/as]

When brightcove loads the player we listen for the template loaded event

[as]
_player.addEventListener(ExperienceEvent.TEMPLATE_LOADED, onTemplateLoaded);
[/as]

Now that we have our first metric to work with we send that information to google and start working on our next metric:

[as]
protected function onTemplateLoaded(evt:ExperienceEvent):void
{
//Time to load tracking
timeToLoad = (new Date().time – startTime);
tracker.trackEvent(String(playerID), String(playlistID),”Player Load Time”, timeToLoad);

//Get the Experience Module
expModule = _player.getModule(APIModules.EXPERIENCE) as ExperienceModule;

//Get Modules from BEML
_videoItem = expModule.getElementByID(“videoPlayer”) as VideoPlayerModule

//Now that the template is ready we can start tracking media events
_videoItem.addEventListener(MediaEvent.BEGIN, onBegin);

}
[/as]

Next is to track when the user sees the first video playing:

[as]
protected function onBegin(evt:MediaEvent):void
{
//This is fired each time a new video begins. One way around this is to
//set a Boolean as to if any video has started – or remove the event listener
//since we were tracking other items we chose to leave the listener alone
if (videoStarted == false)
{
timeToLoad = (new Date().time – startTime)
tracker.trackEvent(String(playerID), String(currPlaylistID),”First Video Playing”, timeToLoad);
}
videoStarted = true;
}
[/as]

Our final metric was one that we were most interested in. This tracks the time spent actually viewing the entire video player.

The solution to this is very simple. Our solution was to use a timer based solution as follows. You can download the foomonger later classes here. Or just use a the built in Flash Timer.

[as]
Later.call(this, sendEvery10, 5000, true);

protected function sendEvery10():void
{
Later.call(this, sendEvery10, 10000, true);

if (firstTimeRecord)
{
tracker.trackEvent(String(playerID), String(currPlaylistID),”Amount Spent Viewing”, 5);
firstTimeRecord = false;
}
else
{
tracker.trackEvent(String(playerID), String(currPlaylistID),”Amount Spent Viewing”, 10);
}

}
[/as]

This report will now show you how long your video player is live on a persons computer. If you want to track this on a per session basis you would just want to add a random variable as follows:

[as]
tracker.trackEvent(String(playerID), String(currPlaylistID + “-” +myRandomVar ,”Amount Spent Viewing”, 10);
[/as]

Hopefully this saves some of you a lot of time with implementation into your own video players.

If you or your clients need any help, feel free to contact our interactive agency. We will be happy to assist.


4 responses so far, want to say something?

  1. linkfeedr » Blog Archive » Tracking Time : Brightcove with GAForFlash Event Tracking - RSS Indexer (beta) says:

    […] Tracking VA:F [1.1.7_509]please wait…Rating: 0.0/5 (0 votes cast) This article was found on . Click here to visit the full article on the original website.When your business is making money based on time then tracking time is of obvious importance. With […]

  2. localToGlobal » Blog Archive » news review -> 16th week of 2009 says:

    […] > Tracking Time : Brightcove with GAForFlash Event Tracking […]

  3. Cameron says:

    This is a great post – one thing I’d like to point out is that GA has an upper limit of about 500 Events per Session

    This means it can get hairy for long form video aggregator playback experiences that need to track time spent on video to a fine granularity.

    For those experiences it might be worth just settling on a 25% – 50% – 75% – 100% quadrant metrics tracking.

  4. admin says:

    Hey Cameron,

    You’re right we are limited to 500 events so for longer video sessions this could be an issue. 500 Events per session would give you around 45 minutes of data. Luckily the attention span of most people (unless they are watching a movie) will be well within the 45 minutes per session.

    In this case the customer was more interested in seconds watched down to a 5 second mark rather than milestones such as 25 to 100%.

    One other thing that can be done is setting the tracking for every 10 seconds which would increase your session tracking to around an 1 hour and 25 minutes.

Leave a Reply