问题描述
< a href =http://example.com/test.html
onclick =_ gaq.push(['_ link','http:/ /example.com/test.html']);
class =noFloat
target =_ blank>
点击我
< / a>
这段代码有问题。没有返回false;我有一个新窗口,没关系,但同一个网址也在同一个父窗口中打开。然后我有两个相同内容的窗口。我认为问题是_gaq.push的重定向请帮助我!谢谢!
_link
会将您当前的网页替换为链接页。因此,您应该始终返回false,因为Google Analytics负责此链接的重定向。
另外,Google不支持属性_blank。所以你必须找到解决办法。
$ b
_gaq.push(['_ setAllowLinker',true ]);
函数_gaLink(a){
url = a.href
_gaq.push(function(){
if(a.target =='_blank'){
window.open(_gat._getTrackers()[0] ._ getLinkerUrl(url));
} else {
_gaq.push(['_ link',url]);
}
});
返回false;
}
现在您可以将其称为Google Analytics(分析)_link。
$ b
< a href =http://example.com/test.html
onclick =return _gaLink(this);
class =noFloat
target =_ blank>
点击我
< / a>
<a href="http://example.com/test.html"
onclick="_gaq.push(['_link', 'http://example.com/test.html']);"
class="noFloat"
target="_blank">
Click Me
</a>
I have a problem with this code. Without return false; i have a new window and it's ok, but the same url is also open in the same parent window. Then i have two windows with the same content. I think the problem is the redirect of the _gaq.push Please help me! Thank you!
_link
will replace your current page with the link page. So you should always return false because Google Analytics will be in charge of the redirection for this link.
Also Google doesn't support the attribute _blank. So you have to find a way around.
_gaq.push(['_setAllowLinker', true]);
function _gaLink(a) {
url = a.href
_gaq.push(function() {
if (a.target == '_blank') {
window.open(_gat._getTrackers()[0]._getLinkerUrl(url));
} else {
_gaq.push(['_link', url]);
}
});
return false;
}
Now you can call it instead of Google Analytics _link.
<a href="http://example.com/test.html"
onclick="return _gaLink(this);"
class="noFloat"
target="_blank">
Click Me
</a>
这篇关于OnClick的谷歌分析和目标_blank。链接不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!