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

后端 未结 8 696
生来不讨喜
生来不讨喜 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:26

    Can you not use your server-side language to output the code at the bottom of each page? Have a function such as output_ga() and call that. That way you can change it in one place.

提交回复
热议问题