Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions dist/videojs.ga.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* videojs-ga - v0.4.2 - 2015-02-06
* Copyright (c) 2015 Michael Bensoussan
* videojs-ga - v0.4.2 - 2016-04-26
* Copyright (c) 2016 Michael Bensoussan
* Licensed MIT
*/
(function() {
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

videojs.plugin('ga', function(options) {
var dataSetupOptions, defaultsEventsToTrack, end, error, eventCategory, eventLabel, eventsToTrack, fullscreen, loaded, parsedOptions, pause, percentsAlreadyTracked, percentsPlayedInterval, play, resize, seekEnd, seekStart, seeking, sendbeacon, timeupdate, volumeChange;
var dataSetupOptions, defaultsEventsToTrack, end, error, eventCategory, eventLabel, eventsToTrack, fullscreen, getEventLabel, loaded, parsedOptions, pause, percentsAlreadyTracked, percentsPlayedInterval, play, resize, seekEnd, seekStart, seeking, sendbeacon, timeupdate, volumeChange;
if (options == null) {
options = {};
}
Expand All @@ -27,6 +27,13 @@
percentsAlreadyTracked = [];
seekStart = seekEnd = 0;
seeking = false;
getEventLabel = function() {
if (typeof eventLabel === 'function') {
return eventLabel();
} else {
return eventLabel;
}
};
loaded = function() {
if (!eventLabel) {
eventLabel = this.currentSrc().split("/").slice(-1)[0].replace(/\.(\w{3,4})(\?.*)?$/i, '');
Expand Down Expand Up @@ -106,12 +113,12 @@
ga('send', 'event', {
'eventCategory': eventCategory,
'eventAction': action,
'eventLabel': eventLabel,
'eventLabel': getEventLabel(),
'eventValue': value,
'nonInteraction': nonInteraction
});
} else if (window._gaq) {
_gaq.push(['_trackEvent', eventCategory, action, eventLabel, value, nonInteraction]);
_gaq.push(['_trackEvent', eventCategory, action, getEventLabel(), value, nonInteraction]);
} else if (options.debug) {
console.log("Google Analytics not detected");
}
Expand Down
6 changes: 3 additions & 3 deletions dist/videojs.ga.min.js

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

7 changes: 5 additions & 2 deletions src/videojs.ga.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ videojs.plugin 'ga', (options = {}) ->
seekStart = seekEnd = 0
seeking = false

getEventLabel = ->
return if typeof eventLabel is 'function' then eventLabel() else eventLabel

loaded = ->
unless eventLabel
eventLabel = @currentSrc().split("/").slice(-1)[0].replace(/\.(\w{3,4})(\?.*)?$/i,'')
Expand Down Expand Up @@ -116,11 +119,11 @@ videojs.plugin 'ga', (options = {}) ->
ga 'send', 'event',
'eventCategory' : eventCategory
'eventAction' : action
'eventLabel' : eventLabel
'eventLabel' : getEventLabel()
'eventValue' : value
'nonInteraction' : nonInteraction
else if window._gaq
_gaq.push(['_trackEvent', eventCategory, action, eventLabel, value, nonInteraction])
_gaq.push(['_trackEvent', eventCategory, action, getEventLabel(), value, nonInteraction])
else if options.debug
console.log("Google Analytics not detected")
return
Expand Down