The problem is that it sometimes takes a while to load, and my jQuery ready () functions do not run until they are executed. I would like to move the GA code itself to the end of the ready () function. I'm not looking for additional click tracking integration - I just want my ready () scripts to run first.
My questions are: 1) Will moving the GA code disrupt their tracking statistics in any way? And also, 2) Do I need to emulate the use of two script tags (one of which generates an external script tag and one that calls the function)? If so, why and what is the best way to do this in jQuery function?
To explain # 2, here's the GA code that now immediately precedes the closing body tag:
<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-8704511-1"); pageTracker._trackPageview(); } catch(err) {}</script>
jquery google-analytics
Jerph
source share