Skip to content

Commit

Permalink
track the engine used (html5/flash) along with the source (ogg, mp4, …
Browse files Browse the repository at this point in the history
…...)
  • Loading branch information
mickey committed Sep 15, 2013
1 parent b232920 commit d9e44fe
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,34 @@ 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)
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```
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.
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']```
```[ 'loaded', 'percentsPlayed', 'start', 'end', 'seek', 'play', 'pause', 'resize', 'volumeChange', 'error', 'fullscreen', 'srcType']```

Most of the events are selft explanatory, here's the ones that may need more details:

- ```srcType```: will send the engine along with the source type being played. exemple: ```html5/mp4```
- ```percentsPlayed```: will send an 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.
This options goes with the ```percentsPlayed``` event. Every ```percentsPlayedInterval``` percents an event will be sent to GA.
**default:** 10


## TODO

- [ ] track the engine used (html5/flash) along with the source (ogg, mp4, ...)
- [x] track the engine used (html5/flash) along with the source (ogg, mp4, ...)
- [ ] track the time to download the video
8 changes: 7 additions & 1 deletion dist/videojs.ga.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/videojs.ga.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/videojs.ga.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ vjs.plugin 'ga', (options) ->
dataSetupOptions = parsedOptions.ga if parsedOptions.ga

deafultsEventsToTrack = [
'loaded', 'percentsPlayed', 'start',
'loaded', 'percentsPlayed', 'start', 'srcType'
'end', 'seek', 'play', 'pause', 'resize',
'volumeChange', 'error', 'fullscreen'
]
Expand All @@ -33,8 +33,15 @@ vjs.plugin 'ga', (options) ->
loaded = ->
unless eventLabel
eventLabel = @currentSrc().split("/").slice(-1)[0].replace(/\.(\w{3,4})(\?.*)?$/i,'')

if "loadedmetadata" in eventsToTrack
_gaq.push(['_trackEvent', eventCategory, 'loadedmetadata', eventLabel])

if "srcType" in eventsToTrack
tmpSrcArray = @currentSrc().split(".")
sourceType = tmpSrcArray[tmpSrcArray.length - 1]
_gaq.push(['_trackEvent', eventCategory, 'srcType', "#{@techName}/#{sourceType}"])

return

timeupdate = ->
Expand Down

0 comments on commit d9e44fe

Please sign in to comment.