I\'m trying to add the asynchronous version of the Google Analytics tracking code to a website.
I\'d like to keep the JavaScript in a separate file, and call it from
You completely miss the point of the asynchronous tracking code. Don't put it in an external file because that's exactly like including the old synchronous GA.
And most importantly don't defer the tracking code to window.onload as it may fire too late.
If you use the asynchronous GA just put it in the top of you document in an inline script tag. This is the recommendation on Google Analytics website as well.
Insert the asynchronous snippet at the bottom of the
section of your pages, after any other scripts your page or template might use.