title: Youtube IFrame API stopped working
body: <p>I'm trying to use basic onPlayerStateChange events in the Youtube IFrame API to track starts/stops/finishes in Google Analytics. The code worked in October, but now the video won't display. GA tracking code is the same and I get the same results in Wordpress and Drupal. Is it changes to the API?</p>
  
  <pre><code>&lt;script&gt; 
  var tag = document.createElement('script'); 
  tag.src = "http://www.youtube.com/iframe_api"; 
  var firstScriptTag = document.getElementsByTagName('script')[0]; 
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  var player; 
  function onYouTubePlayerAPIReady() { 
  player = new YT.Player('player', { 
  height: '461', 
  width: '560', 
  videoId: 'u1zgFlCw8Aw', 
  events: { 
  'onReady': onPlayerReady, 
  'onStateChange': onPlayerStateChange 
  } 
  });  
  }
  function onPlayerReady(event) { 
  event.target.playVideo(); 
  } 
  function onPlayerStateChange(event) { 
  if (event.data ==YT.PlayerState.PLAYING) 
  {_gaq.push(['_trackEvent', 'Videos', 'Play', ‘AnyEvent’ ]); } 
  if (event.data ==YT.PlayerState.ENDED) 
  {_gaq.push(['_trackEvent', 'Videos', 'Watch to End', ‘AnyEvent’]); } } 
  &lt;/script&gt;
  
  &lt;div id="player"&gt;&lt;/div&gt;
  </code></pre>