How to add a tracking javascript code to my form.

  • Profile Image
    Asked on October 08, 2013 at 10:53 AM



    We have been asked by our SEO company to add the below tracking code to the submit button of the form. 

    onClick="_gaq.push(['_trackEvent', 'Newsletter Sign Up', 'Email', 'Cool Grey Link',, false]);" 

    Is this possible? 

  • Profile Image
    Answered on October 08, 2013 at 11:36 AM


    For your inquiry, You would need to download the full source code if you want to make any major changes to the way forms work and to be able to add a custom Javascript to your form.

    To download and edit the whole source code of your form.

    1. Click Setup & Embed


    2. Click Embed Form


    3. Click Source Code


    4. Then to Download the whole code by clicking the "here" highlighted word below the code.


    From there you can put the custom code you wanted to add to your form.

    If you are having trouble, please let us know so that we could further assist you with it.

    We're here to help.

    Thank you for using JotForm.

  • Profile Image
    Answered on October 08, 2013 at 11:50 AM

    In addition to my answer, if this is the complete code you are pertaining to...

    <script type="text/javascript">
      var _gaq = _gaq || [];
      onClick="_gaq.push(['_trackEvent', 'Newsletter Sign Up', 'Email', 'Cool Grey Link',, false]);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

    Or just the same code (google analytics)
    You can instead use the custom URL Thank-You page feature of your form, and add your Google analytics script there.  This way you can point the people who submitted your form to this Thank-You page and get the statistics of people that made a submission.
    Please clarify, and if you need further assistance please let us know.