This is a message.

Setup google analytics

Learn how to track player events in google analytics

standalone demo

Be sure to also check our Analytics plugin. It's an alternative to the scripted approach we demonstrate in this page.

Analytics has a wonderful feature called Event Tracking which is just perfect for Video applications. You can track when your visitors hit play, pause or stop and gather information about the video and at what second each action occurred. Here is a screenshot about statistics that was generated from this page over a one day period:

Google analytics screenshot

Now that you know how to use events it is trivial to set up Google Analytics. Each time your user does something with your video an event will be sent to Google Analytics. Typically you want to know when a video is started and finished. Here is the JavaScript setup for Analytics:

<script type="text/javascript">
var _tracker = _gat._getTracker("[YOUR TRACKING CODE]");
</script>

HTML

Configuration

Now that you have the analytics variable ready, you can use it in your event listeners as follows:

$f("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.18.swf", {
 
clip: {
// track start event for this clip
onStart: function(clip) {
_tracker._trackEvent("Videos", "Play", clip.url);
},
 
// track pause event for this clip. time (in seconds) is also tracked
onPause: function(clip) {
_tracker._trackEvent("Videos", "Pause", clip.url, parseInt(this.getTime()));
},
 
// track stop event for this clip. time is also tracked
onStop: function(clip) {
_tracker._trackEvent("Videos", "Stop", clip.url, parseInt(this.getTime()));
},
 
// track finish event for this clip
onFinish: function(clip) {
_tracker._trackEvent("Videos", "Finish", clip.url);
}
}
 
});

JavaScript

If you have Firebug installed you can see from the Net panel that Google requests are indeed being made. Having Firebug available greatly helps when developing this kind of scripts.

Accessing the Analytics information

You should find the Event information on the Google Analytics interface under Content -> Events. However, event tracking is still in beta and you may not see this link on your interface. Luckily there is a workaround for this. Go to Content -> Overview and you will end up with this kind of URL:

https://www._tracker.com/analytics/reporting/content?id=11880....

Now change that URL so that you replace content with events as follows:

https://www._tracker.com/analytics/reporting/`events`?id=118808....

And BANG you can see events. You can see an overview of all your events.

Viewing Statistics

There are lots of things you can do there. For example, you can study each action separately. Here we have an overview of all pause events that happened during a one day period on this page.

Analytics event statistics

You can see that on average pause has been pressed at 2.670 seconds. Maybe there was something interesting there? Of course you can track any event you want such as entering fullscreen, seeking, resuming from pause etc. You may want to put scripting inside your event calls and only track when certain conditions are met. It's up to you to determine how you want to organize your event tracking.