如何使用 jQuery 插入 Google Analytics 代码
我正在使用一个网站,以前的开发人员已对 30 多个 HTML 页面中的 部分进行了硬编码。也没有页脚。
有没有办法通过 jQuery 将 GTAG 插入到每个页面中?
如有任何反馈,我们将不胜感激!
I'm working with a site where the previous dev has hard-coded the <head>
section in 30+ HTML pages. No footer either.
Is there a way I can insert the GTAG into every page via jQuery?
Any feedback is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
理论上,如果有一个 JavaScript 文件链接到所有其他页面,您可以通过附加添加它。请记住,提供的示例尚未通过 GA 测试,而且考虑到任何人都可以查看您的源代码,这也不是一种安全的方法。
我希望它有帮助,祝你好运! :)
In theory, you could add it through an append if there is a single JavaScript file that links to all other pages. Do keep in mind that the example provided has not been tested through GA and it's also not a safe way to do it considering that your source code will be viewable by any person.
I hope it helps, best of luck! :)