深层链接和 Google Analytics

发布于 2024-09-15 18:00:20 字数 424 浏览 6 评论 0原文

我在使用 Google Analytics(分析)将深度链接作为单独的页面时遇到一些问题。

该网站使用 JQuery 来处理选项卡和深层链接。看看这个页面作为例子:

http://www.albanyservices.com/compliance/#/ic_compliance/ URL 中“#”之后的部分指的是页面中的特定选项卡。当选择新选项卡时,此信息会更新。

目前,谷歌分析并不将每个选项卡视为网站内的单独页面。由于它们都包含单独的内容并直接链接到整个网站,因此我需要找到一种方法让谷歌分析将每个“#”更改视为单独的页面。

任何帮助将不胜感激。提前致谢。

I am having some trouble with Google Analytics picking up deep linking as separate pages.

The site uses JQuery to handle tabs and deep linking. Take a look at this page as an example:
http://www.albanyservices.com/compliance/#/ic_compliance/

The part of the URL after the '#' refers to the specific tab within the page. This is updated when a new tab is selected.

At the moment, google analytics doesn't treat each tab as a separate page within the site. As they all contain individual content and are linked to directly throughout the site, I need to find a way to have google analytics treat each '#' change as a separate page.

Any help would be hugely appreciated. Thanks in advance.

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

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

发布评论

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

评论(1

遮了一弯 2024-09-22 18:00:20

首先,你的“深度链接”想法不是谷歌的。实际上,/compliance/ 是一个单一页面,其中所有这些选项卡的内容都已加载,而 # 只是一个内联锚点,它显示一些相应的内容并隐藏其余内容。这不是新的综合浏览量,而是页面上发生的事件。在大多数情况下,将每个 jQuery 选项卡作为新页面进行跟踪是不正确的,但我可以在这里看到您为什么想要这样做。

您需要做的是每次切换选项卡时调用 _trackPageview() 函数。您可以通过将其放入选项卡的“更改”回调中(在您现在正在处理 $.address.title 之后,该页面源代码的第 143 行)来完成此操作。

这里唯一的问题是页面加载时也会调​​用更改。因此,当页面加载时,您将获得初始的 trackPageview(我们认为它没有达到您想要的效果),然后是该选项卡的第二个。

所以我建议的是,在“选项卡”是比物理页面更有意义的页面结构的页面上,您删除这一行:

_gaq.push(['_trackPageview']);

相反,在选项卡上的 .change 回调内部,调用此:

var _gaq = _gaq || [];
 _gaq.push(['_trackPageview', document.location.pathname + document.location.hash]);

现在还有一个问题这。它将跟踪页面浏览量,例如 /compliance/#/additional_risk_management/

再次强调,Google 并不真正认为 # 意味着新页面,因此,如果由于某种原因该代码不起作用,您'您必须解决从您跟踪的任何页面中删除 # 的问题,如下所示:

var _gaq = _gaq || [];
gaq.push(['_trackPageview', document.location.pathname +     document.location.hash.replace("#/","")])

First off, your idea of "deep linking" is not Google's. In all actuality, /compliance/ is a single page with the content of all of those tabs already loaded in, and the # is just an inline anchor, which displays some corresponding content and hides the rest. It's not a new pageview, but an event happening on the page. In most cases, tracking each jQuery tab as a new page would be incorrect, but I could see here why you would want to.

What you'll want to do is call the _trackPageview() function every time a tab is switched. You can do this by putting it in the tab's "change" callback (after where you're working on $.address.title right now, line 143 of that page's source).

The only problem here is that change gets called when the page loads too. So when the page loaded, you'd have your inital trackPageview (which we've deemed is not doing what you want), and then a second one for the tab.

So what I'd propose is, on pages where "tabs" are the more sensical page structure than physical pages, you remove this line:

_gaq.push(['_trackPageview']);

And instead, inside of the .change callback on the tab, calling this:

var _gaq = _gaq || [];
 _gaq.push(['_trackPageview', document.location.pathname + document.location.hash]);

Now one more problem with this. It will track a pageview to something like /compliance/#/additional_risk_management/

Again, Google doesn't really think # means a new page, so if for some reason that code doesn't work, you'll have to resolve to removing the # from any pages you track, like so:

var _gaq = _gaq || [];
gaq.push(['_trackPageview', document.location.pathname +     document.location.hash.replace("#/","")])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文