PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Add a Google Analytics trackEvent on each field

  1. I am fairly new to gravity forms and JavaScript. But I am wondering if there is a simple way to add an onFocus on each field in a Gravity Form so I can track form behavior in Google Analytics.

    Basically I'd like to change:

    <input type="text" tabindex="1" class="medium" value="" id="input_1_1" name="input_1">

    To

    <input type="text" onfocus="javascript:_gaq.push(['_trackEvent', 'form', 'input_1', 'input_1']);" tabindex="1" class="medium" value="" id="input_1_1" name="input_1">

    Is this possible?

    Thanks for any help on this :)

    Cheers

    Mattis

    Posted 10 years ago on Monday April 23, 2012 | Permalink
  2. Hey Mattis, you should be able to achieve this with this hook:

    http://www.gravityhelp.com/documentation/page/Gform_field_input

    Just be sure to pass the correct name and id when replacing.

    Posted 10 years ago on Tuesday April 24, 2012 | Permalink