1

我正在尝试使用以下脚本跟踪出站链接:

$(document).ready(function(){
    _gaq.push(['_setAccount', 'UA-XXXXXXX-XX']); //hidden number, well configured
    //works
    $("a[href$='pdf']").click(function(){ 
        _gaq.push(['_trackEvent', 'PDF', 'Download', $(this).attr('href') ]);
    });
    //doesn't works
    $("a.external_link").click(function(e){ 
        _gaq.push(['_trackEvent', 'Outbound', 'Click', $(this).attr('href')]);      
    });
});

跟踪 pdf 链接的第一个功能运行良好。第二个没有。我在要跟踪的链接上添加了 target=_blank,所以我认为这不是延迟问题。我已经检查了 Firebug,GA 请求发送良好,所有参数似乎都很好。我点开链接,我知道有些人也是这样做的,这些事件虽然已经实施了 4 天,但在 GA 中并没有出现。

有任何想法吗 ?谢谢 !

4

1 回答 1

0

You mention in your post that all the links to be tracked has a target="_blank" in the attributes.

Why not try something in the order of:

$("a[target$='_blank']").click(function(e){ 
    //gaq function here...      
});

Instead of referencing the href attribute, reference the target attribute rather.

Hope this helps!

于 2012-11-20T10:31:08.627 回答