Google Analytics 中的虚拟综合浏览量取代真实综合浏览量

发布于 2024-10-08 07:54:52 字数 556 浏览 9 评论 0原文

我希望在 Google Analytics(分析)中获得更好的错误页面报告。目前,如果有人在我的网站上执行了导致问题的操作,他们会看到错误页面,而不是他们期望的内容。 URL 保持不变。因此,如果他们访问 www.example.com/view_my_profile 并且他们的个人资料存在问题,他们会在该 URL 看到错误页面。

我想做的是向 Google Analytics 发送类似 www.example.com/error/view_my_profile/ 的虚拟综合浏览量(也许事件可以更好地捕获额外的参数?)。这很容易。但我希望发生此虚拟综合浏览量,而不是 /view_my_profile 真实综合浏览量。因为该真实页面并未被实际查看,并且它将在我的网站上注册额外的页面浏览量。

这是否像在下面的谷歌分析片段中省略 _trackPageView 调用一样简单,还是我在自找麻烦?

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-${gaAccount}-1']);
  _gaq.push(['_trackPageview']);

I'd like to have better error page reporting in Google Analytics. Currently, if someone does something on my site which causes a problem, they see an error page instead of the content they expected. The URL remains the same. So if they went to www.example.com/view_my_profile and there was a problem with their profile, they would see an error page at that URL.

What I'd like to do is send Google Analytics a virtual pageview of something like www.example.com/error/view_my_profile/ (maybe an event captures the extra parameters better?). That's easy enough. But I want this virtal pageview to happen instead of the /view_my_profile real pageview. Because that real page wasn't actually viewed and it would be registering an extra pageview on my site.

Is this as simple as leaving out the _trackPageView call in the google analytics snippet below or am I asking for trouble?

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-${gaAccount}-1']);
  _gaq.push(['_trackPageview']);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

濫情▎り 2024-10-15 07:54:52

事情太复杂了..只需像平常一样使用 _trackPageView ,但将一个值(虚拟 URL)传递给它作为您想要的 URL。它将计为您传递给它的 URL(而不是当前 URL)的页面视图。

Way over-complicating things..just use _trackPageView like normal but pass a value (virtual URL) to it for the URL you want it to be. It will count as a page view for the URL you pass it instead of the current URL.

故事与诗 2024-10-15 07:54:52

您可以轻松完成此操作。只要加载 ga.js,实例化 var gaq 并设置帐户,您就可以进行任何您想要的调用,包括仅具有虚拟浏览量值的 _trackPageview

您甚至不需要调用有机的_trackPageview——您只需进行事件跟踪即可。事实上,您可能需要考虑进行有机页面浏览,并结合向您传递一些详细错误跟踪信息的事件跟踪。由于最多可以有 4 个参数,因此您可以记录更多、更好的结构化数据。

因此,在您的 404 页面上,您可以调用类似以下内容的内容:(

_gaq.push(['_trackEvent', '404 Error', location.pathname, document.referrer, time_stamp_value]);

您之前已将 time_stamp_value 定义为非浮点数字。)

如此简单的内容将允许您为错误创建层次结构,更轻松地对错误进行计数,甚至可以执行以下操作:诸如引用页面和时间戳值之类的内容,而不会弄乱您的综合浏览量信息。

You can do this without complication. As long as you load ga.js, instantiate var gaq, and set the account, you can make any calls you want, including _trackPageview with only a virtual pageview value.

You don't even need to call the organic _trackPageview -- you could just do event tracking. In fact, you might want to consider doing an organic pageview, coupled with an Event Tracking that passes some detailed error tracking info to you. Because there can be up to 4 parameters, you can log more and better structured data.

So, on your 404 page, you could call something like:

_gaq.push(['_trackEvent', '404 Error', location.pathname, document.referrer, time_stamp_value]);

(where you've previously defined time_stamp_value as a non-float Number.)

Something that simple will allow you to create hierarchies for your errors, count them more easily, and even do things like the referring page and a timestamp value, without cluttering your pageview information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文