在 Google Analytics(分析)事件标签中捕获点击的链接网址



>有人知道为什么事件标签的值没有通过吗?我正在尝试捕获事件标签中的点击网址。

这是我的代码。

var url = $(this).attr('href');
$('.s-button').click(function() {
    ga('send', 'event', 'myevent', 'PDF', url);
});
});

你应该这样做:

$('.s-button').click(function() {
    var url = $(this).attr('href');
    ga('send', 'event', 'myevent', 'PDF', url);
});

你这样做的方式,$(this)不是指按钮,而是指更大的东西,没有 href 属性。

最新更新