title: Google Analytics Event Tracking: __utm.gif never finishes loading
body: <p>I have a requirement to track downloads of PDF files in my site.</p>
  
  <p>I am using my own plugin to achieve this: <a href="https://github.com/rsleggett/Quick-Event-Tracking" rel="nofollow noreferrer">https://github.com/rsleggett/Quick-Event-Tracking</a></p>
  
  <p>However, underneath all it does is call the trackEvent function with the correct parameters. My problem is that when tracking the PDF download the event is fired but never finishes loading:</p>
  
  <p>Here's my code:</p>
  
  <pre><code>    &lt;a href="_images/printer-certificate.pdf" class="track-pdf" target="_blank"&gt;Track lots&lt;/a&gt;
      &lt;script&gt;
          $('.track-pdf').gaTrackEvent({
              category: 'Download',
              action: 'PDF',
              labelAttribute: 'href',
              useEvent: true,
              event: 'click'
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>Here's what I see in the Network panel for firebug:</p>
  
  <p><img src="https://i.stack.imgur.com/HiU1o.png" alt="Firebug network panel"></p>
  
  <p>This request never completes and this doesn't seem to be recorded in Google Analytics.</p>
  
  <p>Does anyone have any ideas why?</p>
  
  <p>I have tried adding a delay before changing the document.location like this: </p>
  
  <pre><code>    &lt;a href="_images/printer-certificate.pdf" class="track-pdf" target="_blank"&gt;Track lots&lt;/a&gt;
      &lt;script&gt;
          $('.track-pdf').gaTrackEvent({
              category: 'Download',
              action: 'PDF',
              labelAttribute: 'href',
              useEvent: true,
              event: 'click',
              complete: function (elem, e) {
                  setTimeout(function () { document.location = $(elem).attr('href') }, 100);
                  e.preventDefault();
                  return false;
              }
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>This seems to work - the request completes if I look at it in fiddler. However, this feels hacky and I don't really want my downloads to open in the same window (it breaks my requirements anyway).</p>
  
  <p>Any ideas?</p>