这是我的问题:
我们的页面包含在iframe中(iframe页面的网址-www.iframepage.com)。该页面上有升级链接。当用户单击该链接时,他将被定向到位于不同域(www.billingsite.com/cc.html)上的“计费”页面。
该页面应该在顶部打开(而不是在iframe中)。
如果我使用_link,则GA Cookie值将传递到目标页面,跨域跟踪将起作用,但目标页面将在iframe中打开。
升级
https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiDomainDirectory#_gat.GA_Tracker_._link
我需要一个能够同时提供这两种解决方案的解决方案:目标页面应该在顶部打开(而不是在iframe中),并且GA _utm参数应该传递给目标url,以便跨域跟踪可以正常工作。
任何帮助将不胜感激,谢谢。
最佳答案
_gaq.push(['_ link',url]);函数以您发送的“ url”作为当前窗口的目标。它忽略目标。您需要做的是调用Google函数,然后更新父位置。
您在iFrame中的页面应看起来像链接此
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-xx']);
_gaq.push(['_setDomainName', 'example.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(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>
</head>
<body>
<a href="/link.html" onclick="your_GA_track_link(this.href);">Link</a>
<script>
function your_GA_track_link(url){
_gaq.push(['_link', url]);
self.parent.location.href = url;
return false;
}
</script>
</body>
</html>
关于iframe - 如何将Google Analytics(分析)Cookie从iframe中包含的页面传递到其他域的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11586889/