Skip to content

Instantly share code, notes, and snippets.

@rymai
Created June 8, 2011 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rymai/1014523 to your computer and use it in GitHub Desktop.
Save rymai/1014523 to your computer and use it in GitHub Desktop.
SublimeVideo: Google Analytics integration
<!-- Inside the <head> tag -->
<script type="text/javascript" src="http://cdn.sublimevideo.net/js/YOUR_TOKEN.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['sv._setAccount', 'UA-XXXXX-X']);
_gaq.push(['sv._trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- Inside the <body> tag -->
<video class="sublime" poster="posterframe.jpg" width="640" height="360" preload="none">
<source src="video.mp4" />
<source src="video.ogv" />
</video>
<!-- Just before </body> (or in the <head> tag) -->
<script type="text/javascript">
// Full Google Analytics integration reference here: http://code.google.com/apis/analytics/docs/gaJS/gaJSApi.html
sublimevideo.ready(function() {
sublimevideo.onStart(function(sv) {
_gaq.push(["sv._trackEvent", "Videos", "Play", sv.element.currentSrc + " [" + sv.mode + "]"]);
});
sublimevideo.onEnd(function(sv) {
_gaq.push(["sv._trackEvent", "Videos", "Finish", sv.element.currentSrc + " [" + sv.mode + "]"]);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment