Tracking YouTube embed videos

Extended Google Analytics measuremet.

If you don't use a onYouTubePlayerReady method (it is probable), no additional configuration is required, configuration will be done automatically.

Recommended video format

It is recommended to add parameters enablejsapi=1 and playerapiid=some-unique-id to your video embed code (value some-unique-id is any unique ID). The same unique ID must be set as ID of DOM element embed. Recommended changes are marked in red color.

<object width="480" height="360">
   <param name="movie" value="http://www.youtube.com/v/PZvjQWmJFZA?version=3&amp;hl=cs_CZ"></param>
   <param name="allowFullScreen" value="true"></param>
   <param name="allowscriptaccess" value="always"></param>
   <embed src="http://www.youtube.com/v/PZvjQWmJFZA?version=3&amp;hl=cs_CZ&enablejsapi=1&playerapiid=ytid1" id="ytid1" type="application/x-shockwave-flash" width="480" height="360" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>

Tracking of embed videos in this format can cause problems in earlier versions of Internet Explorer.

Configuration when the method onYouTubePlayerReady is used

If you do not use a method onYouTubePlayerReady, you can skip this paragraph. If you do, _ga.youtube.onYouTubePlayerReady(playerid); must be called in this method. Configuration looks like this:

<object width="480" height="360">
    <param name="movie" value="http://www.youtube.com/v/PZvjQWmJFZA?version=3&amp;hl=cs_CZ"></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowscriptaccess" value="always"></param>
    <embed src="http://www.youtube.com/v/PZvjQWmJFZA?version=3&amp;hl=cs_CZ&
    enablejsapi=1&playerapiid=ytid1" id="ytid1" type="application/x-shockwave-flash" width="480" height="360" allowscriptaccess="always" allowfullscreen="true"></embed>
    </object>
<script type="text/javascript"> function onYouTubePlayerReady(playerid) { // your custom code _gas.youtube.onYouTubePlayerReady(playerid); } </script>

Try it!

You can try measuring the events of YouTube videos here. You can use a plugin GA debug for Chrome to view sent parameters.