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

    How can I add a tracking code to a form field?

    Asked by b2bcontact on May 30, 2012 at 09:41 AM

    We have the following tracking code implemented on our site:

    <script type="text/javascript">
    function appendkeycode()
    {
    // Declare Variables
    var adminkeycode = 'xxxxxx_x';
    var linkurl = 'http://www.cloudday2.com';
    var linktext = 'Cloud Day 2';

    // Insert the keycode
    var sid_pattern= /^[0-9]{6}[_][0-9]{1,4}$/;
    var pageurl=location.href;
    var sid="";
    if(pageurl.indexOf("sid=")!= -1){
    sid=pageurl.substr(pageurl.indexOf("sid=")+4);
    var checkextraval = sid.search("&");
    if(checkextraval != -1)
    sid=sid.split("&")[0];
    }
    if(sid=="" || !sid_pattern.test(sid))
    sid=adminkeycode;
    document.getElementById("link1").innerHTML = '<a target="_blank" href=' + linkurl + '?sid='+sid+'>' + linktext + '</a>';
    }
    appendkeycode();

    </script>

    Along with a body tag of <body onload="appendkeycode();">

    This will allow a tracking code to be appended onto the URL for specific contacts.

    I need to have that tracking code added as a field to the form so I can include it in reporting.

    I read on the forums that using a hidded field is the direction I need to go with this. 

    Can someone please let me know if this is how it should be handled, and if so what should be put in that field as far as "ID" and/or default value for it to work properly?

    Thank you!

    Page URL:
    http://www.cloudday2.com

  • Profile Image

    Answered by b2bcontact on May 30, 2012 at 10:54 AM

    I would really appreciate an answer ASAP on this.

  • Profile Image

    Answered by jeanettebmz on May 30, 2012 at 02:33 PM

    @b2bcontact

    I am sorry for this late reply

    Actually, you would need a Unique ID field , which is also a hidden field and it is an auto-incremental unique number that can be generated for each submission, thus you can accomplish the tracking code you are looking for.

    1. Setup an INDEX , to mark the starting number (example 0)

    2. If you will, set it up with a Prefix , that will go before the ID. Example: JF-0


     

    You can also add a number padding , so a given number of zeros will be added before the ID

    Example: On the image below,  I have added 3 zeroes , so it will look like  JF-000 ; JF-001; JF-002 , etc.

     

    Should you need further assistance, let us know. We are always glad to assist!

     

    Jeanette