mickey / videojs-ga

Google Analytics plugin for video.js
MIT License
138 stars 109 forks source link

What should be logging when debug is true #25

Open ponchorage opened 8 years ago

ponchorage commented 8 years ago

What should I see in the console log when I have set debug to true in the options? I've tried but I'm not seeing anything at all for some reason.

mparpaillon commented 8 years ago

Me neither... But I'm using videojs 5 and this plugin seems to work with v4 only. So I guess that's the reason why I don't see any log

devkinetic commented 7 years ago

I don't see this working in v5 either. Investigating.

devkinetic commented 7 years ago

The plugin works with 5, the debug is working, but not outputting what is expected. I've modified my sendbeacon() function to work as expected. Also, note my plugin initialization.

videojs('thing').ga({
  'eventsToTrack': ['play', 'pause'],
  'debug': true
});
sendbeacon = function(action, nonInteraction, value) {
      if (window.ga) {
        if (options.debug) {
          console.log(action, value);
        }
        ga('send', 'event', {
          'eventCategory': eventCategory,
          'eventAction': action,
          'eventLabel': eventLabel,
          'eventValue': value,
          'nonInteraction': nonInteraction
        });
      } else if (window._gaq) {
        if (options.debug) {
          console.log(action, value);
        }
        _gaq.push(['_trackEvent', eventCategory, action, eventLabel, value, nonInteraction]);
      } else if (options.debug) {
        console.log("Google Analytics not detected");
      }
    };