I have a JavaScript file which is loaded up at the end of my HTML page.
Rather than adding the script code for asynchronous tracking for Google in yet another script I would rather combine the two scripts together.
So instead of this:
<html>
...
<script src="myScript.js">
<!-- google analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_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';
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(ga);
})();
</script>
</html>
I would have that bit of code in the second script tag at the end of my 'myScript.js'.
I have not found one place in google documentation where it suggests to combine the script with yours.
How can I solve this problem?