Adding Google Analytics event code to the Submit button

  • andrewmetropolis
    Asked on October 23, 2015 at 9:34 AM

    We have an analytics manager that wants us to  implement the code below

    The developer will place the following code within the code of the submission link:

     

     
    onDISABLEDclick="ga('send', 'event', { eventCategory: 'Contact', eventAction: 'Form Completed'});”
     
     
    It should look something like this for the contact form:
     
     

    Please help me to understand how to do this.

  • Boris
    Replied on October 23, 2015 at 12:38 PM

    Your analytics manager is asking you to add a little custom script/code into the form, which can't be done with our online forms. In order to add custom scripts, you will have to get the source code of your form.

    You will then add the script to the source code, and paste the full code into your website in place of the currently embedded JotForm form.

    The change that your manager is asking to be implemented should be quite simple. You will only need to paste this part inside the Submit button of your form's source code:

    onDISABLEDclick="ga('send', 'event', { eventCategory: 'Contact', eventAction: 'Form Completed'});"

    If this is about your Contact Desktop Form, 51043579032147, then you would be changing this part of your source code:

    <button id="input_14" type="submit" class="form-submit-button"> Submit </button>

    Into this:

    <button id="input_14" type="submit" class="form-submit-button" onDISABLEDclick="ga('send', 'event', { eventCategory: 'Contact', eventAction: 'Form Completed'});"> Submit </button>

    This will do what your analytics manager has asked for. Please let us know how it goes.

  • andrewmetropolis
    Replied on October 23, 2015 at 1:32 PM

    Excellent. I did manage to figure this out since posting, but thanks for confirming.

  • Mike_G JotForm Support
    Replied on October 23, 2015 at 2:48 PM

    On behalf of my colleague, Boris, you're most welcome! We're glad to know that everything is good. Should you have any other concerns or questions, please feel free to let us know. Thank you.