title: New Google Analytics code into external file
body: <p>New Google Analytics code looks like one below:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
   var _gaq = _gaq || [];
   _gaq.push(['_setAccount', 'UA-0000000-00']);
   _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;
  </code></pre>
  
  <p><strong>How to move the whole new Google Analytics Asynchronous Tracking Code into an external JavaScript file?</strong> </p>
  
  <p>I'm asking especially about "var _gaq = _gaq || []; [...]" part because I know it's possible to move the rest e.g.</p>
  
  <p><em>index.html</em></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
   var _gaq = _gaq || [];
   _gaq.push(['_setAccount', 'UA-0000000-00']);
   _gaq.push(['_trackPageview']);
  
  &lt;/script&gt;
  &lt;script src="include.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p><em>include.js</em></p>
  
  <pre><code>function includeGA()
  {
   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);
  }
  
  $(document).ready(function()
  {
   includeGA();
  });
  </code></pre>
  
  <p>I've already tried to place the "var _gaq = _gaq || []; [...]" code into various locations but nothing worked.</p>