Tracking Streaming Windows Media - a quick Web Analytics HACK
| posted by Dennis R. Mortensen Sunday, November 25, 2007 |
This is not a post about particular online video KPI’s (which is a separate post I will most certainly do), but a HACK on how to actually retrieve the information.
So... let’s get to it. Using the following HTML object:
<OBJECT id='DennisMediaPlayer' width="280" height="280" classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' standby='Loading...' type='application/x-oleobject' >
<param name='fileName' value="http://visualrevenue.com/blog/video/superman-video.wmv">
<param name='animationatStart' value='true'>
<param name='transparentatStart' value='false'>
<param name='autoStart' value="false">
<param name='showControls' value="true">
<param name='loop' value="false">
<param name="ShowStatusBar" value="true">
</OBJECT>
We get the following result:
(..and please be so kind as to interact with the video, so that I get some more data to play with)
Using the windows media player playState property we are provided with the following properties:
- Stopped - Playback of the current media item is stopped.
- Paused - Playback of the current media item is paused. When a media item is paused, resuming playback begins from the same location.
- Playing - The current media item is playing.
- ScanForward - The current media item is fast forwarding.
- ScanReverse - The current media item is fast rewinding.
- Buffering - The current media item is getting additional data from the server.
- Waiting - Connection is established, but the server is not sending data. Waiting for session to begin.
- MediaEnded - Media item has completed playback.
- Transitioning - Preparing new media item.
- Ready - Ready to begin playing.
- Reconnecting - Reconnecting to stream.
- Online video started
- Online video positive consumption action
- Online video negative consumption action
- Online video ended
With the video object active on the site (as you see it in this post) AND the actions set up in my web analytics tool (as shown above). The next step is to create a function, that you can use to capture actions without a page-refresh. (the code below is how to do it in IndexTools, but most tools will provide you with a way to do this)
function onclickactiontracking (actionnumber)
{
var tracking_object = createITT();
tracking_object.ACTION = actionnumber;
tracking_object.submit_action();
}
With the above code in place, we now have everything needed to do the actual online video tracking. Tapping in to the DennisMediaPlayer object we can chose which events to collect. As an example, I have set the following up for the video in this post:
<script language="Javascript" type="text/javascript" for="DennisMediaPlayer" event="PlayStateChange(NewState)">
switch (NewState)
{
case 1: // Stopped (negative)
onclickactiontracking(14);
break;
case 2: // Paused (positive)
onclickactiontracking(13);
break;
case 3: // Playing
onclickactiontracking(11);
break;
case 4: // ScanForward (negative)
onclickactiontracking(14);
break;
case 5: // ScanReverse (postitive)
onclickactiontracking(13);
break;
case 8: // Media Ended
onclickactiontracking(12);
break;
}
</script>
Conclusion:
That is it! You are now collecting online video event metrics and as said, this post does not hold any information on WHAT to collect (KPI’s) or HOW to analyse the collected data. More about that later.. Cheers - AND do ping me if anybody is going to SES in Chicago beginning December. We should meet up! :-)
N.B.
A test on the collected data shows that I am not catching the Media Ended event. note to myself; must look into that later :-)
Labels: Hack, Superman, Web Analytics, Windows Media, WMV




