Giter Club home page Giter Club logo

vimeo.ga.js's Introduction

Google Analytics Vimeo Video Tracking

Tracking Vimeo Player Events with Google Analytics.

Usage

Include the scripts in the body section of the HTML document, just before the </body> tag. You’ll need to be running on a web server instead of opening the file directly in your browser. Flash and JS security restrictions will prevent the API from working when run locally.

Basic

<iframe src="http://player.vimeo.com/video/22439234?api=1" width="640" height="390" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js'></script>
<script src="path/to/vimeo.ga.min.js"></script>

With some options

<iframe src="http://player.vimeo.com/video/22439234?api=1" width="640" height="390" frameborder="0" data-progress="true" data-seek="true" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js'></script>
<script src="path/to/vimeo.ga.min.js"></script>

The data-progress and data-seek attributes enable tracking of progress and skip events.

The iframe embeds a Vimeo video player and allows Vimeo to serve an HTML5 player rather than a Flash player for mobile devices that do not support Flash.

Requirements

  • jQuery 1.4.3 or higher
  • Google Analytics Tracking Code (asynchronous ga.js or Universal Analytics analytics.js)
  • The end user must be using a browser that supports the HTML5 postMessage feature. Most modern browsers support postMessage, though Internet Explorer 7 does not support it.

Browser Support

Tested in Chrome (21), Firefox (15), Safari (5,6), IE (8,9). Also tested on iOS.

Event Tracking

All player events are only tracked once. Restarting the video will not reset the event trackers.

Default event trackers

  • Category: Vimeo
  • Action:
    • Started video: when the video starts playing.
    • Paused video: when the video is paused.
    • Completed video: when the video reaches 100% completion.
  • Label: URL of embedded video on Vimeo.

#####Example (ga.js)

_gaq.push(['_trackEvent', 'Vimeo', 'Started video', 'http://player.vimeo.com/video/22439234', undefined, true]);
_gaq.push(['_trackEvent', 'Vimeo', 'Paused video', 'http://player.vimeo.com/video/22439234', undefined, true]);
_gaq.push(['_trackEvent', 'Vimeo', 'Completed video', 'http://player.vimeo.com/video/22439234', undefined, true]);

#####Example (analytics.js)

ga('send', 'event', 'Vimeo', 'Started video', 'http://player.vimeo.com/video/22439234');
ga('send', 'event', 'Vimeo', 'Paused video', 'http://player.vimeo.com/video/22439234');
ga('send', 'event', 'Vimeo', 'Completed video', 'http://player.vimeo.com/video/22439234');

Progress event trackers

  • Category: Vimeo
  • Action:
    • 25% Progress: when the video reaches 25% of the total video time.
    • 50% Progress: when the video reaches 50% of the total video time.
    • 75% Progress: when the video reaches 75% of the total video time.
  • Label: URL of embedded video on Vimeo.

#####Example (ga.js)

_gaq.push(['_trackEvent', 'Vimeo', 'Played video: 25%', 'http://player.vimeo.com/video/22439234', undefined, true]);
_gaq.push(['_trackEvent', 'Vimeo', 'Played video: 50%', 'http://player.vimeo.com/video/22439234', undefined, true]);
_gaq.push(['_trackEvent', 'Vimeo', 'Played video: 75%', 'http://player.vimeo.com/video/22439234', undefined, true]);

#####Example (analytics.js)

ga('send', 'event', 'Vimeo', 'Played video: 25%', 'http://player.vimeo.com/video/22439234');
ga('send', 'event', 'Vimeo', 'Played video: 50%', 'http://player.vimeo.com/video/22439234');
ga('send', 'event', 'Vimeo', 'Played video: 75%', 'http://player.vimeo.com/video/22439234');

Seek event tracker

  • Category: Vimeo
  • Action:
    • Skipped video: when the video is skipped forward or backward.
  • Label: URL of embedded video on Vimeo.

#####Example (ga.js)

_gaq.push(['_trackEvent', 'Vimeo', 'Skipped video forward or backward', 'http://player.vimeo.com/video/22439234', undefined, true]);

#####Example (analytics.js)

ga('send', 'event', 'Vimeo', 'Skipped video forward or backward', 'http://player.vimeo.com/video/22439234');

Bounce rate

The event trackers do not impact bounce rate of the page which embeds the video. The value of the opt_noninteraction parameter is set to true.

Issues

Have a bug? Please create an issue here on GitHub!

Changelog

0.3 (November 6, 2013):

  • Added support for Universal Analytics (analytics.js)
  • Updated documentation.

0.2 (February 3, 2013):

  • Code cleanup.
  • Fixed a bug in pause event tracking.
  • Updated documentation.

0.1 (October 12, 2012):

  • Initial release.

License

Licensed under the MIT license.

Copyright (C) 2012-2013 Sander Heilbron, http://sanderheilbron.nl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

vimeo.ga.js's People

Contributors

sanderheilbron avatar mrrobwad avatar chrisnicola avatar

Watchers

James Cloos avatar Matt Jones avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.