CardinalPath / gas

Google Analytics on Steroids. A Google Analytics implementation with more power features.
Other
593 stars 78 forks source link

"You must be using the iframe method of embedding videos" #74

Open Joostan opened 8 years ago

Joostan commented 8 years ago

Does this mean i can use the: YouTube IFrame Player API?

i.e.

      var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('mydiv', {
          height: '390',
          width: '640',
          videoId: 'XXXXXXX',
        });
      }

Thanks

janker67 commented 5 years ago

Did you find an answer to your question? We are trying to find a way to pass a Video Name vs. the Video URL into the event label. using the API might be a workaround.

vpodk commented 5 years ago

@janker67, try the getVideoData method, it returns the author, title and video_id:

window.onYouTubeIframeAPIReady = function() {
  var player = new YT.Player('player', {
    ...
    'events': {
      'onStateChange': function(event) {
        var data = event.target.getVideoData();
        console.log(data.title);
      }
    }
  })
};
screen shot 2019-01-16 at 1 27 22 am