What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Adding Google Analytics event code to the Submit button

    Asked by andrewmetropolis on October 23, 2015 at 09: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:

     
    onClick="ga('send', 'event', { eventCategory: 'Contact', eventAction: 'Form Completed'});”
     
     
    It should look something like this for the contact form:
     
    <input id=”contact-submit” class=”button” type=”submit” value=”Submit” onClick="ga('send', 'event', { eventCategory: 'Contact', eventAction: 'Form Completed'});">
     

    Please help me to understand how to do this.

    Page URL:
    http://theencoreclub.com/contact.html

    analytics contact form google analytics custom code custom script submit onclick onclick
  • Profile Image
    JotForm Support

    Answered by Boris 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:

    onClick="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" onClick="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.

  • Profile Image

    Answered by andrewmetropolis on October 23, 2015 at 01:32 PM

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

  • Profile Image
    JotForm Support

    Answered by Mike_G on October 23, 2015 at 02: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.