Google Analytics 和 Colorbox - 跨域跟踪
通过我们的 GA 代码,我们正在跟踪多个域和子域,并且我们仅通过几个自我引用就可以正确跟踪大部分代码。最大的问题是我们使用 Colorbox 作为模态窗口,并且我需要能够附加代码访问这些页面以消除自我推荐。
我已经做了很多搜索,并在 JavaScript 中进行了工作以找到解决方法,但没有运气。
如果我将 onClick="_gaq.push(['_link', $(this).attr('href')]);return false;"
添加到 a 标签以打开模式窗口,当页面使用来自 Google 的附加查询字符串参数刷新时,它会脱离模式窗口并接管整个浏览器窗口。我尝试过构建自定义函数而不仅仅是直接单击,并且得到了相同的结果。我找到的唯一参考是2010 年的这篇文章。
我在这里不知所措。我在想也许我可以获取 utmcc 信息预链接并将其提前附加到 URL,但没有找到从会话中获取该信息的方法。
With our GA code, we are tracking multiple domains and subdomains, and we have the main bulk of the code tracking properly with only a couple of self-referrals. The biggest issue revolves around the fact that we use Colorbox for modal windows, and I need to be able to attach code to these pages to eliminate self referrals.
I've done a lot of searching, and working around in JavaScript to find a work-around, with no luck.
If I add onClick="_gaq.push(['_link', $(this).attr('href')]);return false;"
to the a tag to open the modal window, when the page refreshes with the attach querystring params from Google, it breaks out of the modal window and takes over the entire browser window. I've tried building a custom function rather than just a straight onclick, and I get the same result. The only reference I have found is this article from 2010.
I'm at a loss here. I was thinking maybe I could grab the utmcc info pre-link and append it to the URL ahead of time, with no luck on finding a way to grab that from the session.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
_link
是_getLinkerUrl
。您只需转换 URL,即可在 JavaScript 中动态地获取链接器,而无需使用便利函数(在本例中为不方便)。 (假设 jQuery,因为您使用的是 colorbox)。
假设该链接上的标记类似于
Click!
...我只推荐这种方法如果链接不超过 1 或 2 个;对于大量链接(20+),它可能会对性能产生影响。这是一个演示: http://jsfiddle.net/XscWT/
_link
is a convenience wrapper over_getLinkerUrl
.You can just convert the URL to have the linker dynamically in JavaScript without using the convenience function (which in this case is inconvenient). (Assuming jQuery, since you're using colorbox).
Assuming the markup on that link is something like
<a href="..." class="colorboxlink">Click!</a>
...I'd only recommend this approach if it's no more than 1 or 2 links; for a large number of links (20+), it can have performance impacts. Here's a demo: http://jsfiddle.net/XscWT/
这是我最终使用的代码,感谢 yahelc 的帮助。
This is the code I ended up using, thanks to yahelc for the help.