title: Javascript Redirect with Google Analytics
body: <p>I need help figuring out how to successfully redirect while including Analytics code.</p>
  
  <ul>
  <li>I have a subdomain setup <a href="http://buuf.fractalsystems.org">http://buuf.fractalsystems.org</a></li>
  <li>The subdomain is actually just a subfolder <a href="http://fractalsystems.org/buuf">http://fractalsystems.org/buuf</a></li>
  <li>I have an HTML file in that subfolder which redirects to <a href="https://market.android.com/developer?pub=Fractal%20Systems">https://market.android.com/developer?pub=Fractal%20Systems</a></li>
  </ul>
  
  <p>The code for that redirect file:</p>
  
  <pre><code>&lt;head&gt;
  &lt;script type="text/javascript"&gt;
  function delayedRedirect(){
      window.location = "https://market.android.com/developer?pub=Fractal%20Systems"
  }
  &lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-1234567-8']); &lt;!--I have my real ID there--&gt;
    _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;
  &lt;/head&gt;
  &lt;body onLoad="setTimeout('delayedRedirect()', 3000)"&gt;
  &lt;h2&gt;ADW.BuuF.Theme is no more! You will be redirected to new and better apps in 3 seconds.&lt;/h2&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This works as a redirect only if I don't include my Analytics code. I've tried moving the code around with no change.</p>
  
  <p><strong>QUESTION</strong>
  How can I add a redirect, of any kind, and still be able to track with Google Analytics?</p>
  
  <p>I've tried PHP redirects with no success and am pretty sure htaccess redirects wont help although I'm open to suggestions.</p>
  
  <p>The reason I'm using a JavaScript redirect is so I can continue to track with Google Analytics and also show a little message or make a custom page with the delay.</p>
  
  <p>Thanks for any help. Doesn't have to be JS, please, any input is welcome if you know of a solution.</p>