Instructions for JW Player version 5.0
The Anvato Analytics Plugin for JW Player is a small flash module (14kB, swf) that tracks both user engagement and video player statistics. Once activated, it will collect statistics and deliver them to the Anvato Analytics server farm so that you can view analytics online at http://analytics.anvato.com . Because the plug-in sends data silently to your Anvato analytics account, you will not notice anything different about your player after it is installed.
Note that, JW player uses (http://longtail.com/plug-ins) as the default plug-in directory to load its plug-ins. If your player does not use the default plug-in directory, you need to download the Anvato Analytics plug-in for JW for version 5.X flash player and place it in your site's plug-in directory.
Integrating Anvato Analytics with an existing instance of the JW player is simple: If your player is a JW Player 5.0 or above, then it will automatically load Plugins from JW's servers based on simple settings in your HTML embed code. All you need to do is set your 'plugins' flashvar to include 'anvatoanalytics'. Note that, JW player uses default plugin directory to load plugins, if your player does not use default plugin directory, you need to download Anvato Analytics plug-in for JW for version 5 and place it in your site's plugin directory.
Here are examples of how to use the Anvato Video Analytics plugin with your JW player. Because the plugin sends data silently to your Anvato analytics account, you won't notice anything different about your player once it's installed. For more information about configuring the plugin and retrieving results from Anvato Analytics, read the Anvato analytics User Guide.
<script type="text/javascript"> var so = new SWFObject('player.swf','single','700','450','9'); so.addParam("allowfullscreen","true"); so.addParam("flashvars" "file=video.flv& start-highlightplugins=anvatoanalytics&anvatoanalytics.tracker=XXXXXXXXend-highlight;"); so.write('mydiv'); </script>
<script type="text/javascript"> var so = new SWFObject('player.swf','single','700','450','9'); so.addParam("allowfullscreen","true");so.addParam("plugins","anvatoanalytics"); so.addParam("anvatoanalytics.tracker","XXXXXXXX");so.write('mydiv'); </script>
<embed src="http://www.yoursite.com/player.swf" width="400" height="320" allowscriptaccess="always" allowfullscreen="true" flashvars="start-highlightplugins=anvatoanalytics&anvatoanalytics.tracker=XXXXXXXXend-highlight;" />
Set the Flashvar property anvatoanalytics.debug to true ["anvatoanalytics.debug=true"] in your player generation script. The download pacakage has sample html (player.html) to show how to test the intgeration.
<script type="text/javascript"> var so = new SWFObject('player.swf','single','700','450','9'); so.addParam("allowfullscreen","true"); so.addParam("video","yourvideo.flvs"); so.addParam("title","Your test video");so.addParam("plugins","anvanalytics"); so.addParam("anvatoanalytics.tracker","XXXXXXXX"); so.addParam("anvatoanalytics.debug","true")so.write('mydiv'); </script>
Once the anvatoanalytics.debug property is set, the integrated analytics module will pass activity logs to the JavaScript function displayAnalyticsLogs(string) for reporting.Add fllowing javascript code into your test html page
<script type="text/javascript"> var logs =""; var once = '1'; function displayAnalyticsLogs(a){ logs = logs + a + '
'; document.getElementById('analyticslogs').innerHTML = logs; } </script> <div id="analyticslogs"> </div>
View your test HTML page (clear your cache if necessary).
Upon loading the video you should see an initialization message: "Anvato Analytics 1.5.xxxx is initialized. Tracking Key=XXXXXXXX (your tracking key here)". If you see this message then your player has successfully load and activate the Analytics module.

For each video, you should see three video/player event message. "Player Event: Loaded" when the plugin is ready, "Video Event: Started" when the video starts playing and "Video Event: Metadata" when plugin received the metadata from video. These three messages indicates that the anlaytics plugin is working.
Play a video using your player, then log into your Anvato Analytics account to view your reports. Please note that it can take up to 30 minutes for statistics to appear on your account.
Anvato video analytics server are monitoring the sites where the your player and plugin is loaded for increase security and integrity of video analytics data. To improve the security and flexibility of your player instance you may wish to keep the Anvato Analytics module separate from your JW player. This requires you to place an instance of the Analytics Module on your server and reference it with your JW Player.
If you use any standard JW player (version 4.1 and above), download the pre-compiled version of JW Player which has integrated with Anvato Analytics plugin: JW Player with Anvato Analytics
Add the correct properties to the Flashvar object.
<script type="text/javascript"> var so = new SWFObject('player.swf','single','700','450','9'); so.addParam("allowfullscreen","true"); so.addParam("flashvars", "file=video.flv &start-highlighttracker=XXXXXXXX&anvatoanalytics=plugins/anvatoanalytics.swfend-highlight"); so.write('mydiv'); </script>
Download Anvato Analytics Module for Flash Players: Anvato Analytics
If you use JW player that you have modified the source and customized your player, Add the following code block to Player.as: Replace the XXXXXXX wth your tracker ID. Once complied, the player fully integrated with Anvato analaytics plugin.
import flash.display.Loader; import flash.net.URLRequest; private var swfLoader:Loader = new Loader(); public var analytics:Object = null; // this dynamicly loads the anvato analaytics plugin protected function loadAnvatoAnalytics():void{ swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,anvatoAnalyticsLoaded); var analytic_plugin:String = "anvatoanalytics.swf"; if (this.root.loaderInfo.parameters['anvatoanalyticsplugin']) analytic_plugin = String(this.root.loaderInfo.parameters['anvatoanalyticsplugin']); var ur:URLRequest = new URLRequest(analytic_plugin); swfLoader.load(ur); } // this section initialize the anvato analytics private function anvatoAnalyticsLoaded(e:Event):void{ try{ analytics = e.currentTarget.content; if (analytics){ var jwObject:Object = new Object(); jwObject.model = model; jwObject.view = view; jwObject.controller = controller; jwObject.key = 'xxxxxxxx'; jwObject.type = 'jw'; jwObject.name = 'jwpc'; jwObject.version = config['version']; jwObject.url = this.root.loaderInfo.url; analytics.debug = Boolean(this.root.loaderInfo.parameters['debug']); analytics.initialize(jwObject,null); } } catch(err:Error){ }; }
Modify the loadMVC function: add the following line of code:
loadAnvatoAnalytics();
So your code looks like this:
protected function loadMVC(evt:SPLoaderEvent=null):void { controller = new Controller(config,skin,sploader); model = new Model(config,skin,sploader,controller); view = new View(config,skin,sploader,controller,model); controller.closeMVC(model,view); addModels(); addPlugins();loadAnvatoAnalytics();sploader.addEventListener(SPLoaderEvent.PLUGINS,startPlayer); sploader.loadPlugins(); };
Set the Flashvar property debug to true ["debug=true"] in your player generation script. The download pacakage has sample html (player.html) to show how to test the intgeration.
<script type="text/javascript"> var so = new SWFObject('player.swf','single','700','450','9'); so.addParam("allowfullscreen","true"); so.addParam("video","yourvideo.flvs"); so.addParam("title","Your test video");so.addParam("debug","true");so.write('mydiv'); </script>
Once the debug property is set, the integrated analytics module will pass activity logs to the JavaScript function displayAnalyticsLogs(string) for reporting. Add fallowing javascript code into your test html page
<script type="text/javascript"> var logs =""; var once = '1'; function displayAnalyticsLogs(a){ logs = logs + a + '
'; document.getElementById('analyticslogs').innerHTML = logs; } </script> <div id="analyticslogs"> </div>
View your test HTML page (clear your cache if necessary).
Upon loading the video you should see an initialization message: "Anvato Analytics 1.5.xxxx is initialized. Tracking Key=XXXXXXXX (your tracking key here)". If you see this message then your player has successfully integrated the Analytics module.

For each video, you should see three video/player event message. "Player Event: Loaded" when the plugin is ready, "Video Event: Started" when the video starts playing and "Video Event: Metadata" when plugin received the metadata from video. These three messages indicates that the anlaytics plugin is working.
Play a video using your player, then log into your Anvato Analytics account to view your reports. Please note that it can take up to 30 minutes for statistics to appear on your account.