With the analytics.js Vimeo Plugin you can quickly get started collecting Vimeo player events into the Segment ecosystem.
The plugin is distributed as both an NPM package and as a direct export via CDN.
Simply add the following script tag to the head of your site,
VimeoAnalytics will then be available as part of the global
# latest stable $ npm install @segment/vimeo-analytics
To initialize the plugin you will need to give it access to the Vimeo video player instance(s) running on your page. This is done using the initialize method:
<iframe src="https://player.vimeo.com/video/76979871" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> <script src="https://player.vimeo.com/api/player.js"></script> <script> var iframe = document.querySelector('iframe'); var player = new Vimeo.Player(iframe); var VimeoAnalytics = window.analyticsPlugins.VimeoAnalytics var vimeoAnalytics = new VimeoAnalytics(player) vimeoAnalytics.initialize() </script>
That’s it! The plugin will now begin listening to the Vimeo player for events and respond by firing the corresponding Segment Video Spec events on analytics.js.
The following Segment Video Spec events are tracked by this plugin:
- Video Playback Started
- Video Playback Completed
- Video Playback Paused/Resumed
- Video Content Started/Completed
The following Segment Video Spec properties are automatically attached to the above events:
- Total Length
- Video Player