我已经设置了我们的GA代码来处理跨域跨浏览器跟踪。谷歌分析 - 跨浏览器跟踪与jquery不添加cookie
我们的GA代码:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_gaq.push(['_setDomainName', 'firstdomain.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackEvent', 'Error-404', 'page: ' + document.location.pathname + document.location.search,' ref: ' + document.referrer ]);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
jQuery的代码添加_link的onClick元素到页面上:
$(document).ready(function() {
// Add onClick _link to all <a> elements on page where href contains sister sites
$("a[href*='seconddomain.com'],a[href*='thirddomain.com'],a[href*='fourthdomain.com']").click(function() {
_gaq.push(['_link', this.href]);
return false;
});
的问题是,虽然我知道你不看链接变化在页面上,当你点击它时,cookie应该在新链接的浏览器地址栏中可见,但这不是发生的事情。
有谁看到我做错了什么?
谢谢!
谢谢蜡笔小新。我关闭了该功能,但点击时仍然没有在URL地址栏中看到cookie。 – Yazmin 2013-04-30 20:17:06
@Yazmin根据你的评论编辑我的答案 – 2013-05-01 15:43:57
谢谢蜡笔小新。重定向是问题,虽然我无法使用.preventDefault和.setTimeout显示传递的cookie。还有其他建议吗? – Yazmin 2013-05-01 20:23:35