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
- Flex SDK - Download Flex SDK 3.3
- Ant - Download Ant
Recommended
- Flex Builder - Download Flex Builder 3
- Flash Player Debugger version - Download Flash Player Debugger version
- A local web server (http) for testing
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.
| Event | Description |
| AnalyticsButtonEvent.BUTTONPRESS | Dispatched when any button is pressed. |
| AnalyticsContentEvent.TICK | Dispatched whenever the media time changes. |
| AnalyticsContentEvent.SECTIONVIEWED | Dispatched whenever a unique section of video is viewed. |
| AnalyticsContentEvent.START | Dispatched when a new piece of media starts playback. |
| AnalyticsContentEvent.COMPLETE | Dispatched when a piece of media completes playback. |
| AnalyticsContentEvent.MAXVIEWED | Dispatched at the end of playback / when the user navigates away from the page with the max view point. |
| AnalyticsContentEvent.AMOUNTVIEWED | Dispatched 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.PERCENTAGEVIEWED | Dispatched at the end of playback / when the user navigates away from the page with the percentage of unique video viewed. |
| AnalyticsErrorEvent.ERROR | Dispatched when a player error occurs. |
| AnalyticsInteractionEvent.FULLSCREEN | Dispatched when the player is triggered to enter a fullscreen state. |
| AnalyticsInteractionEvent.UNFULLSCREEN | Dispatched when the player is triggered to exit a fullscreen state. |
| AnalyticsInteractionEvent.LINK | Dispatched when the player is triggered to follow the player link. |
| AnalyticsInteractionEvent.MUTE | Dispatched when the player is triggered to enter a muted state. |
| AnalyticsInteractionEvent.UNMUTE | Dispatched when the player is triggered to leave a muted state. |
| AnalyticsInteractionEvent.NEXT | Dispatched when the player is triggered to go to the next item in the playlist. |
| AnalyticsInteractionEvent.PLAY | Dispatched when the player is triggered to start playing. |
| AnalyticsInteractionEvent.PAUSE | Dispatched when the player is triggered to pause. |
| AnalyticsInteractionEvent.PREV | Dispatched when the player is triggered to go to the previous item. |
| AnalyticsInteractionEvent.FF | Dispatched when the player is triggered to seek ahead. |
| AnalyticsInteractionEvent.RW | Dispatched when the player is triggered to seek back. |
| AnalyticsInteractionEvent.STOP | Dispatched when the player is triggered to stop. |
| AnalyticsPlayerEvent.LOAD | Dispatched when the player window loads. |
| AnalyticsPlayerEvent.CLOSE | Dispatched when the player window closes. |
| AnalyticsUserInfoEvent.BANDWIDTH | Contains information about the user's bandwith / speed. |
| AnalyticsUserInfoEvent.FLASHVERSION | Contains information about the user's Flash version. |
| AnalyticsUserInfoEvent.PLAYERVERSION | Contains information about the version of the player sending analytics data. |
| AnalyticsUserInfoEvent.PLAYERURL | Contains 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.
