Instructions for Custom Flex based PlayersThe Anvato Analytics Plugin for flash is a small flash module (20kB, swf) that tracks both user engagement and video player statistics. Any flash video player can load this module dynamically. 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.
If you use a custom video player that use standard Adobe classes to display video, such as Video Display or Video Classes, you will integrate analytics with your player using Anvato Analytics ActionScript API. This is easier than it sounds: All you need to do is add a small piece of code to your player, download and initialize the plug-in.
This section gives and example how to load and integrate your player with Anvato Analytics plugin dynamically for flash player uses Flex VideoDisplay or VideoPlayer Clasess to play video. Download the sample Flash player example (Flex VideoDisplay/Video Player Class) Insert the following SWF loader code to into your player to load the Analytics module.
import com.anvato.analytics.PluginLoader; private var anvatoplugins:PluginLoader; public var analytics:Object = null; private function LoadAnvatoPlugins(callbackFunction:Function=null):void { try{ if (callbackFunction) this.addEventListener('AnvatoPluginsReady',callbackFunction); anvatoplugins = new PluginLoader(); anvatoplugins.addEventListener(PluginLoader.PLUGINS_READY, onAnvatoPluginsReady); anvatoplugins.config['analytics'] = PluginLoader.FLEX_PLAYER_3_X; anvatoplugins.load(); } catch(e:Error){ } } private function onAnvatoPluginsReady(e:Event):void{ ExternalInterface.call("displayAnalyticsLogs",'Plugin Load Delay: '+anvatoplugins.loadDelay.toString()); if (anvatoplugins.plugins['analytics']){ analytics= anvatoplugins.plugins['analytics'].content; if (analytics){ analytics.config['tracker'] = this.parameters['tracker']; analytics.config['url'] = this.url; analytics.config['name'] = 'myflexplayer 3.3'; analytics.config['video'] = this.videoplayer; //analytics.debug =true; analytics.initialize(); analytics.listenComponent(shareComponent); } } this.dispatchEvent(new Event('AnvatoPluginsReady')); }
After the plugin loaded and ready, you should call analytics.onLoad() whenever a new video is loaded/or start playing. This will pass the video title and url to analytics plugin about the current video. Without this step, analytics module cannot send information to server. Proper setting of url and title (optional) therefore is important.
private function LoadVideo():void{ videoplayer.source = video_url; if (analytics) analytics.onLoad(video_url,video_title); } videoplayer.load();
The Analytics module will automatically begin listening to video events after initialization. There is an exposed API for tracking user interaction events: analytics.listenComponet(component:Object). To track a user event you need to call the Analytics Event API when the action occurs.
// to start listneing anavato events for spefic plugin/component if (analytics) analytics.listenComponent(your_custom_embed_plugin_object); import com.anvato.analytics.AnalyticEvent; function embedPluginStart():void{ this.dispatchEvent(AnalyticEvent.event(AnalyticEvent.User_Embed,''); }
Alternatively, you can send specific Anvato Analytics events to the plugin using the sendEvent() API call.
private function ShareVideo():void{ this.shareComponent.visible = true; if (analytics) analytics.sendEvent( AnvatoAnalytics.User_Share,'facebook'+':'+videoplayer.playheadTime.toString() ); } }
Set the Flashvar property debug to true ["debug=true"] in your player generation script. Once the debug property is set, the integrated analytics module will pass activity logs to the JavaScript function displayAnalyticsLogs(string) for reporting.
Set the Flashvar properties video and title in your HTML.
View your HTML page (clear your cache if necessary).
Upon loading the video you should see an initialization message: "Anvato Analytics 1.3.XXX 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 analytics 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 15 minutes for statistics to appear on your account.