Flash plugin: Analytics Google Analytics event tracking
Introduction
The Analytics plugin tracks Flowplayer events to your Google Analytics account. Many useful player and clip events are tracked by default, including Play, Begin, Start, Pause, Resume, Seek, Mute, Unmute, Full Screen, and Full Screen Exit. An external JavaScript function allows you to customize the labels for these events as well as track only a subset of these events. Another external JavaScript function allows you to track custom events using the current clip's status time.
This plugin tracks events by host page path and clip name. If this plugin is used in an embedded third-party website and the allowScriptAccess embed parameter is set to "always" then the plugin will track the host page path of the external site. Note that this is not possible on some third-party sites like MySpace, which always reset the allowScriptAccess embed variable to "never". In this case, the host page will show up as 'Unknown'.
Download (Version 3.2.0)
Features
- Tracks most standard Flowplayer player and clip events: Start, Play, Pause, Resume, Seek, Finish, Mute, Unmute, Full Screen, Exit Full Screen.
- In most cases will track the domain name and web page of an embedded video
- Allows you to configure which events will be tracked
- Configurable event label names for language localization
- External function called trackEvent() to track custom events in addition to the ones Analytics already tracks: by host page, the current clip's file name, and player time
- External function called setLabel() to change event label names at runtime, as well as turn on or off specific event tracking
To create a Google Analytics account and view event tracking for your website, visit the Google Analytics website. Visit their support site for more information on how to set up and use your Google Analytics account.
You will need the analytics.swc library from gaforflash in your ant external libraries path if you want to compile Analytics into your flowplayer.swf. Supply all of the gatracker parameters in your BuiltInConfig.as to use for external website object tag embedding and tracking. See here for more information on how to compile plugins into the player.
The actual event tracking info uses the following format: "http://website.com/page_flowplayer_is_embedded_on", "Play", "http://yoursite.com/video_clip_name", "time_in_seconds"
"http://flowplayer.org/demos/Analytics/index.php", "Play", "http://flowplayer.org/demo/video.flv", "12"
Example
This example shows Analytics in debug mode so you can see the events that are tracked as they occur. If debug is set to false then nothing will appear and the events will be sent to Google Analytics. They may take up to a day to show up, be patient.
<a
href="http://vod01.netdna.com/vod/demo.flowplayer/flowplayer-700.flv"
style="display:block;width:500px;height:330px;"
id="player">
<!-- splash image inside the container -->
<img src="/img/home/flow_eye.jpg" alt="Search engine friendly content" />
</a>
Here is the configuration:
$f("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.2.swf", {
plugins:{
gatracker: {
url: "flowplayer.analytics-3.2.0.swf",
labels: {
start: "Start",
play: "Play",
pause: "Pause",
resume: "Resume",
seek: "Seek",
stop: "Stop",
finish: "Finish",
mute: "Mute",
unmute: "Unmute",
fullscreen: "Full Screen",
fullscreenexit: "Full Screen Exit"
},
debug: true,
trackingMode: "AS3",
googleId: "UA-5877901-1" // your Google Analytics id here
}
}
});
This code shows the full range of configuration options for Analytics - not all of them are required. For the default AS3 mode (no pre-existing ga.js on the html page) the only required parameters are url and googleId. The url is the path to the Analytics plugin. The googleId is the Google ID that you can get from Google Analytics after you set up your website for tracking. The debug parameter determines whether or not the event tracking information is sent to Google or simply displayed in an overlay over your media. The labels object allows you to rename the event labels or if the event label is false instead of a string, Analytics will not track those events.
For example, if you don't want to receive tracking information for mute and unmute actions and you want to rename the 'Resume' event to 'Unpause', your labels object would look like this:
labels: {
resume: "Unpause",
mute: false,
unmute: false
}
Analytics Bridge Mode example
In this mode the plugin uses the ga.js JavaScript functionality to send the tracking events to Google Analytics. To use this mode you should include the ga.js (or the Analytics script block) in your embedding HTML page. Typically you use this mode if you already use ga.js to track the traffic of the embedding page.
<a
href="http://vod01.netdna.com/vod/demo.flowplayer/flowplayer-700.flv"
style="display:block;width:500px;height:330px;"
id="bridge">
<!-- splash image inside the container -->
<img src="/img/home/flow_eye.jpg" alt="Search engine friendly content" />
</a>
In Bridge mode, the only parameters are url and trackingMode. The url is the path to the Analytics plugin. The trackingMode is set to 'Bridge' to tell Analytics that you'll be using the existing page's ga.js pageTracker object.
$f("bridge", "http://releases.flowplayer.org/swf/flowplayer-3.2.2.swf", {
plugins:{
gatracker: {
url: "flowplayer.analytics-3.2.0.swf",
trackingMode: "Bridge",
// flowplayer.org uses and older version of the Analytics JS code,
// we need to modify the name of the tracker object accordingly
bridgeObject: "_tracker"
}
}
});
Configuration
Here is a list of all Analytics specific clip properties. These go under the gatracker object in the player configuration:
| property | datatype | default | description |
|---|---|---|---|
url |
String | Required. The path to your local Analytics plugin. | |
trackingMode |
String | AS3 | Optional. If this is set to "Bridge" instead of "AS3", you must pass in the existing page tracking object (bridge_object). |
bridgeObject |
String | window.pageTracker | Optional. Can be used to modify the tracking object name when tracking_mode is "Bridge". |
googleId |
String | Required if tracking_mode is "AS3". Your Google ID which should start with UA-. | |
debug |
Boolean | true | Optional. If true, no tracking information will be sent to Google and will be displayed on an overlay over the video instead. |
labels |
Object | (see below) | Optional. Each of the event labels may be renamed, or turned off by setting the label name to false. |
Here is a list of configuration options for the labels object. See more information on player events and clip events.
| property | default | description |
|---|---|---|
start |
"Start" | The onStart event |
play |
"Play" | The onPlay event |
pause |
"Pause" | The onPause event |
resume |
"Resume" | The onResume event |
seek |
"Seek" | The onSeek event |
stop |
"Stop" | The onStop event |
finish |
"Finish" | The onFinish event |
mute |
"Mute" | The onMute event |
unmute |
"Unmute" | The onUnmute event |
fullscreen |
"Full Screen" | The onFullscreen event |
fullscreenexit |
"Full Screen Exit" | The onFullscreenexit event |
Scripting
The Analytics plugin has the following custom methods that can be used at runtime:
| method | example | description |
|---|---|---|
| setLabel(event:String, newEventLabelName:String) | $f().getPlugin("gatracker").setLabel("pause", "Pausa"); | Changes the label name for the given event to newEventLabelName. If newEventLabelName is false Analytics will stop tracking for that event. If the function is subsequently called with a new newEventLabelName tracking will start for that event again. This can be used for language localization |
| trackEvent(eventLabelName:String) | $f().getPlugin("gatracker").trackEvent("My Custom Event Name"); | Immediately tracks an event with newEventLabelName as the event label using the current clip's time. You can use this function to track events on the page and synchronize them to a specific clip's timeline. For example, if a user clicks on a link on the page you can call this function to track which clip and at what time the user clicked. This function could also be used to track events from another Flowplayer plugin. |
Download
Get latest version of the Flowplayer Analytics plugin.
| flowplayer.analytics-3.2.0.swf | just the working Flash file to get you going |
| flowplayer.analytics-3.2.0.zip | working Flash file (swf) + README.txt and LICENCE.txt |
| flowplayer.analytics-3.2.0-src.zip | source code |
Please right-click and choose "Save link as..." (or similar)
See the version history for this tool.
NOTE We are no longer providing packed scripts. Althought they may have smaller file size they offer less performance than minified scripts. See details from JavaScript Library Loading Speed.
Found a bug?
If you encounter problems in this script, please send a bug report to the bug reporting forum. If you have a problematic page, including a direct URL to that page is by far the most effective way of helping us to find a bug.