AnalyticsComponent Development Guide

Introduction

The Analytics framework is designed to bring your analytics platform to the JW Player as quickly and easily as possible, with little or no maintenance required.

Tools

Required

Building your AnalyticsComponent

Setup

We have made an excellent implementation of AnalyticsComponent available to you in src/MyAnalyticsComponent.as. Although it's just a skeleton, it's an excellent jumping off point.

You should rename this file to something a bit more meaningful, like your company's name. Feel free to simply rename the file, or create a new file and copy in the contents of MyAnalyticsComponent.

Be sure to update the name of the class, the name of the constructor function, and the MyAnalyticsComponent name, starred below.

public class *MyAnalyticsComponent* implements Sprite extends PluginInterface {
...
	public function *MyAnalyticsComponent*() {
		super();
		// Your code here
	}
...
}

After you rename the file, you'll still have to make a few changes in build/build.properties order to ensure that everything works smoothly. Specifically

  • application.package - References the path from src to the MyAnalyticsComponent, e.g. com/longtailvideo/analytics/
  • application.class - The filename of the actionscript file containing your AnalyticsComponent, e.g. MyAnalyticsComponent
  • application.name - The filename of the output SWF, e.g. myanalyticscomponent

Implementation

Events

While your AnalyticsComponent can access the player itself, you should listen for events from the base Analytics Component and perform its actions based on those events. This will ensure consistent event flow regardless of player version.

Listening for Events

You can listen for the following events by adding an event listener to Analytics.analytics.dispatcher.

EventDescription
AnalyticsButtonEvent.BUTTONPRESSDispatched when any button is pressed.
AnalyticsContentEvent.TICKDispatched whenever the media time changes.
AnalyticsContentEvent.SECTIONVIEWEDDispatched whenever a unique section of video is viewed.
AnalyticsContentEvent.STARTDispatched when a new piece of media starts playback.
AnalyticsContentEvent.COMPLETEDispatched when a piece of media completes playback.
AnalyticsContentEvent.MAXVIEWEDDispatched at the end of playback / when the user navigates away from the page with the max view point.
AnalyticsContentEvent.AMOUNTVIEWEDDispatched at the end of playback / when the user navigates away from the page with the amount (seconds) of video viewed. Note: This will double-count the sections that were watched more than once.
AnalyticsContentEvent.PERCENTAGEVIEWEDDispatched at the end of playback / when the user navigates away from the page with the percentage of unique video viewed.
AnalyticsErrorEvent.ERRORDispatched when a player error occurs.
AnalyticsInteractionEvent.FULLSCREENDispatched when the player is triggered to enter a fullscreen state.
AnalyticsInteractionEvent.UNFULLSCREENDispatched when the player is triggered to exit a fullscreen state.
AnalyticsInteractionEvent.LINKDispatched when the player is triggered to follow the player link.
AnalyticsInteractionEvent.MUTEDispatched when the player is triggered to enter a muted state.
AnalyticsInteractionEvent.UNMUTEDispatched when the player is triggered to leave a muted state.
AnalyticsInteractionEvent.NEXTDispatched when the player is triggered to go to the next item in the playlist.
AnalyticsInteractionEvent.PLAYDispatched when the player is triggered to start playing.
AnalyticsInteractionEvent.PAUSEDispatched when the player is triggered to pause.
AnalyticsInteractionEvent.PREVDispatched when the player is triggered to go to the previous item.
AnalyticsInteractionEvent.FFDispatched when the player is triggered to seek ahead.
AnalyticsInteractionEvent.RWDispatched when the player is triggered to seek back.
AnalyticsInteractionEvent.STOPDispatched when the player is triggered to stop.
AnalyticsPlayerEvent.LOADDispatched when the player window loads.
AnalyticsPlayerEvent.CLOSEDispatched when the player window closes.
AnalyticsUserInfoEvent.BANDWIDTHContains information about the user's bandwith / speed.
AnalyticsUserInfoEvent.FLASHVERSIONContains information about the user's Flash version.
AnalyticsUserInfoEvent.PLAYERVERSIONContains information about the version of the player sending analytics data.
AnalyticsUserInfoEvent.PLAYERURLContains information about the URL of the player sending analytics data.

Testing your AnalyticsComponent

Be sure to test your AnalyticsComponent thoroughly before submitting it to LongTail. If your AnalyticsComponent requires any configuration parameters, be sure to appropriately update settings.xml.

Building the tester

Anytime you want to test your AnalyticsComponent, you should first run the build-debug Ant task. This will compile your SWF (in debug mode) and copy it in our testing framework.

Using the tester

To test your AnalyticsComponent, simply open bin-debug/index.html in any web browser. We recommend that you access this via a local web server because of restrictions in the Flash security model.

Preparing your AnalyticsComponent for distribution

To build a SWF that is ready for distribution, simply run the build-release Ant task. The SWF will appear in bin-release.