https://github.com/mickey/videojs-ga
Google Analytics plugin for video.js
https://github.com/mickey/videojs-ga
Last synced: about 1 year ago
JSON representation
Google Analytics plugin for video.js
- Host: GitHub
- URL: https://github.com/mickey/videojs-ga
- Owner: mickey
- License: mit
- Created: 2013-09-07T20:40:09.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2017-05-25T11:35:51.000Z (about 9 years ago)
- Last Synced: 2025-05-09T00:08:51.016Z (about 1 year ago)
- Language: JavaScript
- Size: 263 KB
- Stars: 138
- Watchers: 22
- Forks: 106
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# videojs-ga
LOOKING FOR A MAINTAINER: [I am looking for a maintainer for this project](https://github.com/mickey/videojs-ga/issues/30)
Google Analytics plugin for video.js
## Getting Started
Download [videojs](http://www.videojs.com/) and [videojs.ga](https://github.com/mickey/videojs-ga)
In your web page:
```html
videojs('video', {}, function() {
this.ga(); // "load the plugin, by defaults tracks everything!!"
});
```
_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'],
'debug': true
});
```
```html
```
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']```
Most of the events are selft explanatory, here's the ones that may need more details:
- ```percentsPlayed```: will send an event every X percents. X being defined by the option ```percentsPlayedInterval```.
####percentsPlayedInterval
This options goes with the ```percentsPlayed``` event. Every ```percentsPlayedInterval``` percents an event will be sent to GA.
**default:** 10
####debug
If set to false, console logs will be ommited
**default:** ```false```
#### ga.js and analytics.js
This plugin supports the ga.js and the newer analytics.js Google Analytics libraries. It autodetects the library you use.
## See information in google
To view the data on Google, access your account in analytics, in left panel click in Behavior > Events > Top Events.
## TODO
- [x] track the engine used (html5/flash) along with the source (ogg, mp4, ...)
- [ ] track the time to download the video