title: Google analytics from jQuery's document.ready() doesn't work
body: <p>I am trying to find a way to add google analytics code from a document.ready() function. The following code doesn't work. </p>
  
  <pre><code>$(document).ready(function () {
               var _gaq = window._gaq || [];
                   _gaq.push(['e._setAccount', 'UA-XXXZZ-1']);
                   _gaq.push(['e._setDomainName', 'company.com']);
                   _gaq.push(['e._trackPageview']);
                   _gaq.push(['a._setAccount', 'UA-XXXYY-1']);
                   _gaq.push(['a._setDomainName', 'company.com']);
                   _gaq.push(['a._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);
                   })();      
  }); 
  </code></pre>
  
  <p>What could the solution be? I can put the piece of code which creates link to ga.js file inside the head tag, but will it solve the problem? </p>
  
  <p>Thanks</p>