-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,68 @@ | ||
# Ga | ||
# videojs-ga | ||
|
||
Google Analytics plugin for video.js | ||
|
||
## Getting Started | ||
Download [videojs](http://www.videojs.com/) | ||
Download [videojs](http://www.videojs.com/) and [videojs.ga](https://github.com/mickey/videojs-ga) | ||
|
||
In your web page: | ||
|
||
```html | ||
<video id="video" src="movie.mp4" controls></video> | ||
<script src="video.js"></script> | ||
<script src="dist/ga.min.js"></script> | ||
<script src="dist/videojs.ga.min.js"></script> | ||
<script> | ||
videojs('video', {}, function() { | ||
var player = this; | ||
player.awesome(); // "awesome" | ||
player.ga(); // "load the plugin" | ||
}); | ||
</script> | ||
``` | ||
|
||
## Documentation | ||
_(Coming soon)_ | ||
_Please note that the Google Analytics script must be loaded before the ga plugin_ | ||
|
||
## Options | ||
|
||
You can provide options to the plugin either by passing them in the javascript or in the html. | ||
|
||
```javascript | ||
player.ga({ | ||
'eventsToTrack': ['fullscreen', 'resize'] | ||
}); | ||
``` | ||
|
||
```html | ||
<video id="video" src="movie.mp4" controls data-setup='{"ga": {"eventsToTrack": ["error"]}}'></video> | ||
``` | ||
|
||
The plugin will take in priority options provided in the javascript, followed by the ones provided in html and finally the defaults. | ||
|
||
The following options are supported: | ||
|
||
####eventCategory | ||
|
||
This is the ```category``` sent to GA. If you don't know what it is please check [GA's doc](https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide) | ||
**default:** ```'Video'``` | ||
|
||
|
||
####eventLabel | ||
|
||
This is the ```label``` sent to GA. If you don't know what it is please check [GA's doc](https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide) | ||
**default:** basename of the video path so if the path is ```http://s3.amazonaws.com/pouet.mp4``` the label would be ```pouet``` | ||
|
||
####eventsToTrack | ||
|
||
The events you want to track. Most of this events are videojs events. Some of them might reflects my needs. | ||
I'm open to add some more if you care to provide a good use case or a pull request. | ||
**default:** every events | ||
```[ 'loaded', 'percentsPlayed', 'start', 'end', 'seek', 'play', 'pause', 'resize', 'volumeChange', 'error', 'fullscreen']``` | ||
|
||
####percentsPlayedInterval | ||
|
||
This options goes with the ```percentsPlayed``` event. Every ```percentsPlayedInterval``` percents an event will be sent to GA. | ||
**default:** 10 | ||
|
||
|
||
## Examples | ||
_(Coming soon)_ | ||
## TODO | ||
|
||
## Release History | ||
_(Nothing yet)_ | ||
- [ ] track the engine used (html5/flash) along with the source (ogg, mp4, ...) | ||
- [ ] track the time to download the video |