title: Attach onClick analytics tracking code in a href link using jQuery
body: <p>I'm pretty new with JavaScript and jQuery and i'm having a hard time attaching onClick Google Analytics tracking inside an A link in our website redesign using jQuery. </p>
  
  <p>I know that I can just do this: </p>
  
  <pre><code>&lt;a href="#" onClick="_gaq.push(['_trackPageview', 'URL']);"&gt;link&lt;/a&gt; 
  </code></pre>
  
  <p>However SharePoint html field deletes the onClick code whenever I put it there so I need a script that does that for me.</p>
  
  <p>So far I have this:</p>
  
  <pre><code>&lt;a class="tracking" href="URL"&gt;Read PDF&lt;/a&gt;
  
  jQuery(document).ready(function($) {
      $(".tracking").click(function() {
          _gaq.push(['_trackPageview', 'url']);
      });
  });
  </code></pre>
  
  <p>The clicked PDF doesn't show up in the real time analytics page when I checked. So I need something that would ensure that when the link is clicked, it shows up in the Analytics tracker in real time. Can I use a script that adds the onClick tracking event inside the A link. </p>
  
  <p>Please help. </p>
  
  <p>Thanks!</p>