Add Google Analytics to multiple Vimeo videos

I was working on a page earlier this week that had a number of Vimeo videos embedded within a scroller. Each video needed to have a unique identifier submitted with the analytics event tracking. The event was to be submitted only when any video started being played. Here is the small chunk of code I used for this. Don’t forget to include the Froogaloop library to access the vimeo player’s events.

var iframes = $('iframe.vimeovideo'); 
    iframes.each(function(i, obj) { 
    $(obj).load(function() { 
     var txt = $(obj).next().text(); // text from an h1 element
     var player=$f(this);
     player.addEvent('ready', function() {
       player.addEvent('play', function(data) {
         _gaq.push(['_trackEvent', 'Video', 'Start', txt,, false]);

Leave a Reply

Your email address will not be published. Required fields are marked *