Tracking JW Player Play event in Google Analytics

You can track how many plays your certain video embedded with JW Player scored in your Google Analytics report Content - Events.

Here's a sample code with comments:

<script type="text/javascript" src="path_to_swfobject_2+/swfobject.js"></script> <!-- calling the callback function (locally it is calledd flashLoaded; available in SWFObject starting from 2.2) -->
<script type="text/javascript" src="path_to_player_5+/jwplayer.js"></script> <!-- requires JW Player 5+ with new API -->

<script type="text/javascript">
var flashvars = {
	file: 'link_to_video.ext', /* path to video */
	image: '/video/wday.jpg' /* static image preloader */
var params = {
  	allowfullscreen: 'true',
var attributes = { id:'player1', name:'player1' }; // not sure you really need those but it was in JWP example so whatever; and it seems to really impact event tracking success
swfobject.embedSWF('/video/player_5_9/player.swf', 'container', '320', '240', '9.0.0', 'path_to_swfobject_2+/expressInstall.swf', flashvars, params, attributes, flashLoaded); 
/* flashLoaded - don't miss this one! */

function flashLoaded(e) /* checks whether the Object was successfully created */ { 
 jwplayer(e.ref).onPlay(function() { _gaq.push(['_trackEvent', 'Videos', 'Play', 'Video Name']);
 /* alert(e.success+'\n'+e.ref.tagName+'\n'+e.ref.innerHTML); // useful for checking is the object is created allright */});

<div id="container"> <!-- the object is created here -->
<!-- put whatever you want inside this one-->
  <p>Install Flash Player to play video</p>
  <p><a href="" target="_blank" rel="nofollow" target="_blank">
<img src="" alt="Get Adobe Flash player" /></a></p>