As on twitter.com:
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push( ['_trackPageview'], ['_setDomainName', 'twitter.com'] ); (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); }()); </script>
Which can be reduced to:
<script> var _gaq=[['_setAccount','UA-XXXX-X'],['_trackPageview'],['_setDomainName','twitter.com']]; (function(d,t){ var g=d.createElement(t),s=d.getElementsByTagName(t)[0]; g.async=1; g.src='//www.google-analytics.com/ga.js'; s.parentNode.insertBefore(g,s) }(document,'script')); </script>
And with $script.js:
<script> $script("//www.google-analytics.com/ga.js", function(){ var t = _gat._getTracker ("UA-XXXXX-X"); t._setDomainName("twitter.com"); //t._initData(); t._trackPageview(); }); </script>