我已經設置了我們的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