admin管理员组文章数量:1327054
I am using Event Tracking on our conversion form to pass the values of a few drop-downs to Google Analytics as events. Our conversion form is an inquiry form for our online degree programs. I only want to pass the values of the fields on form submit, so I have added the following code to the code that runs on successful submission of the form:
$("#App,#InquiryForm").validate({
submitHandler: function (form) {
$(".button").attr("value", "Please wait...");
$(".button").attr("disabled", "disabled");
_gaq.push(
['_trackEvent', 'Inq Form Academic Level', 'Academic Level', $('#AcademicLevel').val()],
['_trackEvent', 'Inq Form Delivery Time', 'Delivery Time', $('#CourseDeliveryTime').val()],
['_trackEvent', 'Inq Form Program Type', 'Program Type', $('#ProgramType').val()],
['_trackEvent', 'Inq Form Program', 'Program', $('#ProgramofInterest').val()]
);
form.submit();
},
The purpose of this is to be able to segment our traffic that converted by what they were interested in. (e.g. What was the browsing behavior of visitors who inquired about our undergraduate degrees vs those that inquired about our graduate degrees).
Unfortunately, only the first event tracking script is running successfully, not the last three (regardless of what order I place them in - the first one is always the only one that is successful).
If you can help me to get this working, that would be fantastic! If not, perhaps some alternate suggestions to get at the data I need?
Thanks
I am using Event Tracking on our conversion form to pass the values of a few drop-downs to Google Analytics as events. Our conversion form is an inquiry form for our online degree programs. I only want to pass the values of the fields on form submit, so I have added the following code to the code that runs on successful submission of the form:
$("#App,#InquiryForm").validate({
submitHandler: function (form) {
$(".button").attr("value", "Please wait...");
$(".button").attr("disabled", "disabled");
_gaq.push(
['_trackEvent', 'Inq Form Academic Level', 'Academic Level', $('#AcademicLevel').val()],
['_trackEvent', 'Inq Form Delivery Time', 'Delivery Time', $('#CourseDeliveryTime').val()],
['_trackEvent', 'Inq Form Program Type', 'Program Type', $('#ProgramType').val()],
['_trackEvent', 'Inq Form Program', 'Program', $('#ProgramofInterest').val()]
);
form.submit();
},
The purpose of this is to be able to segment our traffic that converted by what they were interested in. (e.g. What was the browsing behavior of visitors who inquired about our undergraduate degrees vs those that inquired about our graduate degrees).
Unfortunately, only the first event tracking script is running successfully, not the last three (regardless of what order I place them in - the first one is always the only one that is successful).
If you can help me to get this working, that would be fantastic! If not, perhaps some alternate suggestions to get at the data I need?
Thanks
Share Improve this question edited Jan 15, 2013 at 11:52 Shai 115k39 gold badges256 silver badges393 bronze badges asked Mar 5, 2012 at 19:07 Cail DesrochersCail Desrochers 632 silver badges8 bronze badges 2-
Can you show the code that calls the
_gaq.push
for your events? Is it in anonSubmit
or jquery function??? – jk. Commented Mar 5, 2012 at 19:38 - I updated my original question with more of the surrounding code. I didn't write the initial code, and my knowledge of jQuery is beginner-level. Hopefully this helps. – Cail Desrochers Commented Mar 5, 2012 at 19:44
1 Answer
Reset to default 6I tested pushing multiple events with one push and it worked fine. It may be submitting the form before all the _trackEvents
are pushed.
Try adding a setTimeout
to the form.submit()
to give the _gaq.push
time to send all of them.
setTimeout(function(){ form.submit(); }, 200);
Install Chrome and the Google Analytics Debugger. Look in the console (control, shift, j) for the event tracking processing.
If you don't see all of your events tracking there, then something is up maybe with the form values.
本文标签: javascriptCan I track multiple Google Analytics events at onceStack Overflow
版权声明:本文标题:javascript - Can I track multiple Google Analytics events at once? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742214257a2434276.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论