title: How do I get Google Analytics to track individual images on a slideshow?
body: <p>I have a jQuery slideshow, I'm using the cycle plugin. I'm decent with jQuery, but I don't know how I should tie it in with Google Analytics to show me how many times each image is requested.</p>
  
  <p>I've looked around online but <b>I haven't been able to find any good documentation for it.</b></p>
  
  <p>Can someone give me a simple example and maybe a link to the documentation supporting the example?</p>
  
  <p>Thanks!</p>
  
  <p><b>Edit:</b></p>
  
  <p>The key is just to use this code to send an event:</p>
  
  <pre>
  _gaq.push(['_trackEvent', 'PageLocation', location.href]);
  </pre>
  
  <p>But you need to have the asyncronous syntax of calling Google Analytics, which will probably look something like this:</p>
  
  <pre>
  &lt;script type=&quot;text/javascript&quot;&gt;
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-xxxxxxx-1']);
    _gaq.push(['_setDomainName', 'site.com']);
    _gaq.push(['_trackPageview']);
  
    (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
  
  &lt;/script&gt;
  </pre>
  
  <p>BTW you might need to wait for the document to be ready / loaded before executing the _gaq.push line :)</p>