Skip to content

Commit

Permalink
Add sendGaEventDirectly option
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Khazov committed Nov 2, 2016
1 parent 6c5af22 commit 10228b1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dist/videojs.ga.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@
eventFields.eventValue = value;
}
_this.trigger('gaEvent', eventFields);
if (options.sendGaEventDirectly && window.ga) {
ga('send', 'event', {
'eventCategory': eventCategory,
'eventAction': action,
'eventLabel': eventLabel,
'eventValue': value,
'nonInteraction': nonInteraction
});
}
if (options.debug) {
console.log(eventFields);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/videojs.ga.min.js

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

8 changes: 8 additions & 0 deletions src/videojs.ga.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ videojs.plugin 'ga', (options = {}) ->

@trigger('gaEvent', eventFields)

if options.sendGaEventDirectly && window.ga
ga 'send', 'event',
'eventCategory' : eventCategory
'eventAction' : action
'eventLabel' : eventLabel
'eventValue' : value
'nonInteraction' : nonInteraction

if options.debug
console.log(eventFields)
return
Expand Down

0 comments on commit 10228b1

Please sign in to comment.