从页面预加载内容是否会影响我的 Google 分析统计数据?
我想自己编写一个简单的脚本,使用 AJAX 将主导航栏上每个页面的内容加载到当前页面上的隐藏 div 中。
这只是为了让我可以预加载尽可能多的重要内容,并在用户完成当前页面并想要继续之前将其缓存在用户的计算机上(希望如此)。
我担心每次有人访问时对网站上的每个页面发出请求,真的会破坏我的谷歌分析统计数据的有效性。
AJAX 如何与 Google Analytics 交互?它算作“页面访问”吗?
I'd like to write myself a simple script that uses AJAX to load the content from each page on my main navbar into a hidden div on the current page.
This is just so that I can preload as much of my important content as possible and get it cached on the user's computer (hopefully) before they've finished with the current page and want to move on.
I'm concerned that doing a request for every page on the site, every time someone visits, will really ruin the validity of my google analytics stats.
How does AJAX interact with google analytics? Does it count as a "page visit"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在不运行嵌入脚本的情况下检索每个页面,则 Google Analytics 代码将不会运行,并且不应计为页面视图。我建议在检索每个页面后不要对代码执行任何操作(即不要将内容插入到隐藏的 div 中)。
If you retrieve each page without running the embedded script, then the Google Analytics code would not be run and it should not count as a page view. I suggest not doing anything with the code after retrieving each page (i.e. not inserting the content into a hidden div).
如果您想通过删除页面并将其替换为 ajax 请求来对您的网站进行 ajax 化,那么您在 GA 方面需要做的就是调用 _trackPageView 每当应跟踪页面视图时。
If you want to ajaxify your site by removing pages and replacing them with ajax requests, then all you need to do on the GA side of things is call _trackPageView whenever a page view should be tracked.