Is it possible to put Google Analytics code in an external JS file?

后端 未结 8 708
生来不讨喜
生来不讨喜 2021-02-05 02:56
var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");
document.write(unescape(\"%3Cscript src=\'\" + gaJsHost + \"google-anal         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 03:23

    Yes this is possible. If it is not working then there is something else going on.

    Just a thought, Google Analytics is usually about a day behind in reporting so when you make changes it will take some time before you know it is working. What I like to do is hit a page that does not get traffic very often to assure me that I have my tracking set up correctly.

    Also, you might try making the link an absolute link in your tag. It might just be looking in the wrong place for the analytics code.

提交回复
热议问题