我的网站在一个登录页上有一个表单。我在我的网站上使用谷歌分析。当表格提交时,我想在谷歌分析中以某种方式跟踪它,作为转换(或其他统计数据)。
有人做过类似的事情吗?我知道有一些自定义事件,比如视频点击等,但我想看看表单提交,或者如何为表单提交设置自定义事件。
要跟踪表单提交,您可能需要查看事件跟踪。
如果你使用的是jQuery,你可能会有类似的东西:
<form action="thank-you.html" method="POST">
<!-- Some inputs -->
<!-- ... -->
<input type="submit" value="Send" />
</form>
然后您可以使用跟踪Form交互
(function ($) {
$('form').on('submit', function (event) {
// Temporarily prevent submission of the form:
event.preventDefault();
// Keep a reference to the form:
var form = $(this);
ga('send', 'event', {
'eventCategory': 'Form', // Event Category (Required).
'eventAction': 'Submit', // Event Action (Required).
'eventLabel': 'Form Title', // Event Label (Optional).
'hitCallback': function () {
// Once the Event has been sent to Google Analytics, submit the form:
form.submit();
}
});
});
})(jQuery)
然后,您可以在Google Analytics中将此事件用作目标,以获得有关表单提交的具体见解:https://support.google.com/analytics/answer/1012040?hl=en