title: Attach a Javascript function to an OOTB ribbon button
body: <p>I want to attach a custom javascript function to the out of the box "Download a copy" ribbon button. This is to provide analytics for file downloads done through the ribbon button. </p>
  
  <p>I tried this code, but it doesn't seem to work:</p>
  
  <pre><code>   &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"&gt;
      &lt;/script&gt;
      &lt;script&gt;
      _spBodyOnLoadFunctionNames.push("Trackdownloads");
  
      function Trackdownloads(){
  
          debugger;
          $("a[id='Ribbon.Documents.Copies.Download-Large']").live( "click", 
                    function() {
                        alert('hello');
                    }
              );
  
      }
  
      &lt;/script&gt;
  </code></pre>
  
  <p>Any idea how to get this to work?</p>