简体   繁体   English

Google Analytics(分析)事件跟踪-提交表单时的复选框

[英]Google Analytics Event Tracking - Checkboxes on Form Submission

I have a search form on my website with various checkboxes that filter your search results. 我的网站上有一个搜索表单,其中包含用于过滤搜索结果的各种复选框。 I would like to add event tracking to the checkboxes to track which of them are used the most when users perform a search. 我想将事件跟踪添加到复选框,以跟踪用户执行搜索时使用最多的事件。 We are currently not able to do this server side for various reasons so I would like to do it with GA. 目前,由于各种原因,我们无法在服务器端进行此操作,因此我想使用GA进行此操作。

Now I am aware that you can use an onChange to fire the Event when the check box is clicked, however the user may check and uncheck various boxes before they submit the form. 现在,我知道可以在单击复选框时使用onChange触发事件,但是用户可以在提交表单之前选中和取消选中各个框。 This would result in multiple events being recorded. 这将导致记录多个事件。 For this reason I would only like to fire the events when the form is submitted. 因此,我只想在提交表单时触发事件。

Does anyone know if this is possible and how it could be achieved? 有谁知道这是否可行以及如何实现?

Thanks 谢谢

Execute the Event Tracking method when you're saving your data in back end. 将数据保存在后端时,请执行事件跟踪方法。 The other option is, execute the event in form submitting point. 另一种选择是在表单提交点执行事件。 You can easily do this with Jquery. 您可以使用Jquery轻松地做到这一点。

Use the link below to get the selected check box value, using jquery 使用下面的链接使用jquery获取选定的复选框值

http://api.jquery.com/checked-selector/ http://api.jquery.com/checked-selector/

once you get the selected value, pass it to the Event Tracking method. 获得选定值后,将其传递给事件跟踪方法。

Ex: _gaq.push(['_trackEvent', 'Theme', ' CheckBoxValue ','other_Info']); 例如:_gaq.push([['_ trackEvent','Theme',' CheckBoxValue ','other_Info']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM