Track Youtube Videos: Play, Pause, Stop, and Finish Events

Hello, I’m new to Piwik and new to coding in javascript. However, I’m looking for sample / template code (javascript with PHP if needed) that would capture play, pause, stop, and finish events for Youtube videos. I embed Youtube videos using the iframe tag and primarily need assistance with the javascript portion. However, I would need to know where to place Piwik’s cutom variable or goal track code within the javascript.

I would greatly appreciate any help especially if this is someing you’ve already implemented.

Thank you,
CP

PS: The closest thing I’ve found was the following: 301 Moved Permanently and 301 Moved Permanently, but I’m not sure if this is applicable to Youtube. I’ve also found: YouTube Player API Reference for iframe Embeds  |  YouTube IFrame Player API  |  Google Developers and YouTube Embedded Players and Player Parameters  |  YouTube IFrame Player API  |  Google Developers, but lack the knowledge to bring it all together.

We now have a Media Analytics plugin that tracks Videos & Audio!

More information is available here: http://www.media-analytics.net/ The plugin gives useful insights into media / video / audio analytics and adds many new reports, widgets and segments to Piwik.

Works with HTML5 video & audio, Vimeo and YouTube out of the box. Support for other players can be added easily and is documented in the developer docs. We are also happy to add support for more players upon request, please ping us. After installation the plugin will in most cases directly start tracking data see the setup guide

For a full list of features check out https://plugins.piwik.org/MediaAnalytics . Docs are available at FAQ, User Guide, Developer docs