0

I'd like to track when the user clicks Play on a Youtube video in a Galleria slideshow, for tracking in Google Analytics.

As far as I can tell, Galleria creates an iframe with the src attribute set to your video URL, and not using the YouTube Iframe API, which allows you to listen to events.

So the only way I can think of doing it is implementing a plugin or modifying the Galleria video methods to use the Youtube Iframe API. Unless there's another way (or someone has already done this)?

David Cook
  • 483
  • 7
  • 25
  • Or maybe I could fake it by just listening for the first click on the stage, and assuming it was on the play button.. – David Cook Apr 14 '14 at 05:25

1 Answers1

0

I solved this by using Jquery iframeTracker to listen for the first click on an iframe, like so:

global.video_clicked = false;
    Galleria.ready(function () {
        this.bind("loadfinish", function (e) {
            //Video Plays: Capture the first click anywhere inside the iframe for Google Analytics
            global.video_clicked = false;
            $('.galleria-image iframe').iframeTracker({
                blurCallback: function(){
                    if (!global.video_clicked) {
                        _gaq.push(['_trackEvent', 'Video', 'play', $('.galleria-info-title').text()]);   
                        global.video_clicked = true;
                    }
                }
            });
        });
David Cook
  • 483
  • 7
  • 25