我的网站上显示了一些instagram图片,如下所示
<a href="https://instagram.com/p/aaaaaa/" title="title of instagram image here" target="_new" id="imgLink" ><img src="https://image link here" alt=" "></a>然而,我似乎不能得到这个注册使用谷歌分析,即我希望它被记录在谷歌分析时点击。我正在尝试如下所示
/* Tracks all a href links */
$('a').click(function(e){
ga('send','event','Link (Open Day)', 'Click (Open Day)',$(this).text().trim());
})发布于 2015-06-27 07:09:40
我鼓励您在将该标签传递给ga函数之前将其保存为变量。
有时分析不会立即拾取事件,因为它是一个链接。因此,在这种情况下,我建议您尝试以下代码:
window.onload = function()
{
var myVars = setInterval(function(){ googleads() }, 1000);
function googleads()
{
$('a').click(function(e){
ga('send','event','Link (Open Day)', 'Click (Open Day)',$(this).text().trim());
clearInterval(myVars);
}
}
}很酷的一点是,你可以在控制台上尝试。希望这能帮上忙..注意: ga是通用分析语法。也要注意这一点
https://stackoverflow.com/questions/31077169
复制相似问题