深层链接和 Google Analytics
我在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,你的“深度链接”想法不是谷歌的。实际上,/compliance/ 是一个单一页面,其中所有这些选项卡的内容都已加载,而 # 只是一个内联锚点,它显示一些相应的内容并隐藏其余内容。这不是新的综合浏览量,而是页面上发生的事件。在大多数情况下,将每个 jQuery 选项卡作为新页面进行跟踪是不正确的,但我可以在这里看到您为什么想要这样做。
您需要做的是每次切换选项卡时调用 _trackPageview() 函数。您可以通过将其放入选项卡的“更改”回调中(在您现在正在处理 $.address.title 之后,该页面源代码的第 143 行)来完成此操作。
这里唯一的问题是页面加载时也会调用更改。因此,当页面加载时,您将获得初始的 trackPageview(我们认为它没有达到您想要的效果),然后是该选项卡的第二个。
所以我建议的是,在“选项卡”是比物理页面更有意义的页面结构的页面上,您删除这一行:
相反,在选项卡上的 .change 回调内部,调用此:
现在还有一个问题这。它将跟踪页面浏览量,例如 /compliance/#/additional_risk_management/
再次强调,Google 并不真正认为 # 意味着新页面,因此,如果由于某种原因该代码不起作用,您'您必须解决从您跟踪的任何页面中删除 # 的问题,如下所示:
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:
And instead, inside of the .change callback on the tab, calling this:
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: