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 = {
  	wmode:'opaque',
  	allowfullscreen: 'true',
  	allowscriptaccess:'always'
  	};
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 */});

}
</script>
<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="http://www.adobe.com/go/getflashplayer" target="_blank" rel="nofollow" target="_blank">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

Reference: