var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");
document.write(unescape(\"%3Cscript src=\'\" + gaJsHost + \"google-anal
I came across this post while trying to resolve a similiar issue. After searching further I came across another post that worked for me:
Using Google Analytics asynchronous code from external JS file
I had to move the var _gaq outside of the function it was in so that it became global.
Hope this helps!