Posted By

nicom on 10/18/13


Tagged

javascript jquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Priestd09


Form tracking with JS and Google Analytics


 / Published in: jQuery
 

URL: http://jsfiddle.net/nicomiceli/WK5eN/

Track user interactions with html forms

  1. var array1 = [];
  2. $(document).ready(function () {
  3. $('input').change(function () {
  4. var formbox = $(this).attr('id');
  5. array1.push(formbox);
  6. console.log("you filled out box " + array1);
  7. });
  8. $('#submit').click(function () {
  9. console.log('tracked ' + array1);
  10. //alert('this is the order of boxes you filled out: ' + array1);
  11. _gaq.push(['_trackEvent', 'Form', 'completed', '"' + array1 + '"']);
  12. });
  13. });

Report this snippet  

You need to login to post a comment.