Last active
December 13, 2015 23:19
-
-
Save tjFogarty/4990993 to your computer and use it in GitHub Desktop.
Vimeo tracking object, assuming you're using https://github.com/vimeo/player-api/tree/master/javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//simply use Vimeo.init(); to find the videos and bind the events | |
var Vimeo = { | |
// we can add more events when we need to, e.g. onPause | |
events: { | |
// when videos are ready, we can attach our events | |
ready: function( player_id ) { | |
$f(player_id).addEvent( 'play', Vimeo.events.onPlay ); | |
}, | |
//when the play button is clicked | |
onPlay: function( player_id ) { | |
//clean up the string for track event by removing the hyphens | |
var trackEvString = player_id.replace( /-/g, ' ' ); | |
//track event (GA) | |
if(_gaq) _gaq.push(['_trackEvent', 'Video', 'play', trackEvString]); | |
} | |
}, | |
// collects the videos on the page and binds events | |
init: function() { | |
var i = 0, | |
videos = $( '.vimeo-video' ), | |
length = videos.length, | |
player = null; | |
for ( i; i < length; i++ ) { | |
player = videos[i]; | |
$f( player ).addEvent( 'ready', Vimeo.events.ready ); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment