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

  • Profile Image
    Asked 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 = '';
    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){
    var checkextraval ="&");
    if(checkextraval != -1)
    if(sid=="" || !sid_pattern.test(sid))
    document.getElementById("link1").innerHTML = '<a target="_blank" href=' + linkurl + '?sid='+sid+'>' + linktext + '</a>';


    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!

  • Profile Image
    Answered on May 30, 2012 at 10:54 AM

    I would really appreciate an answer ASAP on this.

  • Profile Image
    Answered on May 30, 2012 at 02:33 PM


    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!