Home | Cool ClickDimensions Features | Pre-fill Forms from Links or Webpages

Pre-fill Forms from Links or Webpages

ClickDimensions includes a great profile management feature, but it is works only when an email is sent with a link to the profile management form, and is limited to data that is on the recipient’s contact or lead record in CRM. It has the advantage that it can all be configured in a graphical UI, but in some scenarios, you might want additional flexibility. Here’s a way you can pre-fill forms using URL parameters and a little javascript.

We’ve kept this example simple to illustrate how it can be done. This form has been pre-populated with an email recipient's first name, last name, job title and email address. (You can also use this technique without sending email, as long as you have a way to add useful parameters in the form’s URL.)


Here’s how this was done:

  1. Use our form designer to create a form. Here we have added fields for first and last name, job title, and email address. Notice the “Code Editor” button. We’ll come back to that in a moment.
  2. Next, we’ll want to get the IDs for each of our fields. Click the “Embed” button and then click the link to where the form is hosted. With the form now open in your browser, you can view the HTML source and locate the IDs of the fields. Copy the fields IDs to add them to your javascript in the following steps.
  3. Back in the Form Builder, click on “Code Editor”. We’ll be inserting some javascript.
  4. Here’s the javascript you’ll want to insert. You can download this sample here. (Note that this is a sample, and will need to be modified for your requirements by a web developer.)
  5. In my email template, I add a link to the form I designed, and I also add parameters to the URL and placeholders where the first and last names, job titles, and email addresses for each recipient will go. The parameters I’ve added to the form’s URL match what I have in the javascript above.


Now, when I send the email to a recipient, the link will be personalized for each recipient, and the javascript will fill in the fields automatically.

There are other scenarios where this can be used. Instead of building the URL and its parameters in an email template, you could build it on your website. For example, if you have a product catalog, with links from each product page to a form where prospects can request a quote, you can pass the product ID and other information to the form via the URL so your prospect doesn’t need to type it in. There are endless possibilities!

Happy Marketing!

About the Author:

Matt Wittemann is a 13-time Microsoft Dynamics CRM MVP and ClickDimensions' Senior Director, Pre-Sales Consulting.


  1. Vikram Patil June 30, 2014 at 2:10 am - Reply

    Can this feature be made available for Surveys.

  2. Vikram Patil July 25, 2014 at 2:12 am - Reply

    For Auto populating forms if there is a Space in the Job Title say for e.g. “marketing Manager” this value when passes to the url auto replaces the space between marketing and manager with %20 which shows on you form as “Marketing%20Manager” to remove this %20 from the field use the below code.

    var jobTitle = getParm(‘JobTitle’);
    var jobTitlen = jobTitle.replace(/%20/g, ” “); // Ads this line of code

    and pass the variable jobTitlen to the below

    JobTitleField.value = jobTitlen;


  3. Vikram Patil July 28, 2014 at 7:21 am - Reply

    Are the parameters passed to the the “Microsite”? else the users will get the wrong details on the form as “lead.firstname” etc in the input field on the form.

    Please let me know.

  4. ClickDimensions July 28, 2014 at 8:21 am - Reply

    No, microsites are not forms. They are just the HTML from your email templates. So they cannot be pre-populated.

  5. jamesd43 September 23, 2014 at 9:48 pm - Reply

    Does this feature work even when the form is embedded through the widget or an iframe?

  6. ClickDimensions September 24, 2014 at 6:15 pm - Reply

    Hi Jamesd43: You should be able to achieve similar results when the form is embedded in another page, rather than as a direct link. It might require a little tinkering with the javascript to reference the parameters in the URL.

  7. Greg Priestley September 13, 2016 at 4:48 am - Reply

    Does this work with embedding as a widget?

    The embed code for the form that we’re provided looks something like:

    var loc = “https://analytics-au.clickdimensions.com//pages/”;


    Where exactly do you append the parameters? I’ve tried a number of permutations but none work. My quick, non proficient, reading of the CDWidget.js is that you can’t append any parameters in – almost looks like you’ve have to hack the CDWidget.js to some custom version for it which obviously isn’t that desirable.

    What am I missing?

    Is there a way to do this?

  8. ClickDimensions September 13, 2016 at 3:26 pm - Reply

    Hi Greg, Please see the previous response. The script in this blog example won’t work with a widget, but you should be able to write similar javascript and place it in the code editor that will.

  9. Sy Nayman August 1, 2017 at 7:22 pm - Reply

    I have a client that needs to conditionally display questions based on their response. The scenario is:
    1. Select items from a check box list
    2. Click “next”
    3. On the subsequent page, the checkboxes that were selected will appear again with additional text field questions.

    We want to use a Javascript that will hide questions on the subsequent page that weren’t selected.

    Please comment on the following:
    1. The code editor does not allow HTML page edits. Where does the code editor insert the Javascript into the survey?
    2. Are there specific Javascript syntax or properties that ClickD will not write if entered in the Code Editor?

    • mm
      ClickDimensions Marketing August 3, 2017 at 5:33 pm - Reply

      Thank you for your question! Custom JavaScript that you add to the code editor is added in a CDATA block near the top of the page’s HTML. If you view your form from the embed link, and then have a look at the HTML source, you will see it there. With regards to syntax: We do not perform any validation or checking on your JavaScript syntax, so anything you add there should be thoroughly tested.

  10. TJWL October 25, 2017 at 6:41 pm - Reply

    Great stuff! Is there an easy way to code for accessing a site protected by a login and password?

    • mm
      ClickDimensions Marketing October 27, 2017 at 7:43 am - Reply

      It depends on the login page. If you can modify it so it accepts a parameter in a link, then this could be done. However, it wouldn’t be a very secure method because someone could easily share the link and thus their login credentials.

  11. Alex Albers April 26, 2018 at 11:23 am - Reply

    I’m not a developer, but is it possible to show a field based on a given answer from another question?

    For instance, I would like to ask how we can contact the person who’s filling out the form. If e-mail is selected then I would like to show an e-mail address field to be filled out and if phone is selected then I would like to ask out a phone number. And how is validation working then? Sure I want to have the e-mail address field requiered when it is asked. Same counts for phone field.

    Hope some one can help me out.

  12. Jonathan May 10, 2018 at 3:26 am - Reply

    Hi, I was wondering if this is still an option as the code within this page doesn’t seem to work even after I have change the field ID? I was going to the link.

    • mm
      ClickDimensions Marketing May 11, 2018 at 10:34 am - Reply

      Yes, this does still work. Double check your JavaScript – in addition to making sure you have the field IDs right, make sure your parameters are all properly set.

  13. Bradley May 18, 2018 at 11:59 am - Reply

    What about if the one of the fields doesn’t have a value in the CRM? the Email will not send through ClickDimensions.

    What do you do to account for blank fields?

    Eg Job title isnt filled in.

    • mm
      ClickDimensions Marketing May 21, 2018 at 7:39 am - Reply

      Thanks for your question, Bradley! This is a trickier situation, but there is FreeMarker that can let you check for the existence of variables and set default values for missing ones. It would be a little harder to write that FreeMarker in the context of a URL, so you might have to first check for the existence of all the variables before including the dynamic link in the HTML, and then have an else statement that just has a plain link if the variables do not exist. We don’t have any examples of this handy, but this blog post goes into depth about if/then/else statements:

  14. coldefy June 6, 2018 at 10:34 am - Reply

    What if the field is a checkbox ? I get the value “yes” or “no” in the url. how can I pre-check the box if i get yes ?
    I have 2 checkboxes, their name are the same as the ID.
    Thank you ,

    • mm
      ClickDimensions Marketing June 7, 2018 at 3:48 pm - Reply

      To set the checkbox value, you would probably want to write some additional javascript that checks the value in the parameter so you can handle whether it is yes or no, and then use something like
      document.getElementById(“checkbox”).checked = true;

  15. Moe July 15, 2018 at 2:14 pm - Reply

    how do I replace + sign in the form with spaces instead ? I am trying to auto populate a US address in the field and I am getting the + sign added with it. please advise. Thank you

    • mm
      ClickDimensions Marketing July 26, 2018 at 8:02 am - Reply

      You would have to URL encode the spaces in the parameters. For example, the parameters might be as follows:
      But you will need to handle the URL encoded space in your JavaScript as well.

  16. Stephan July 31, 2018 at 7:10 am - Reply

    Hi ClickDimensions,

    I am currently struggeling to prefill a survey which is sent to accounts with the account number / name.
    The survey is embedded ba an iframe.
    what i was thinking should work i the following:
    Combining your great tip with the tip described here: http://blog.clickdimensions.com/pre-filling-forms-using-iframes/ in order to pass the parameters to the iframe-link.
    So i added a script to pass some parameters to the iframe and added code folowing your idea from this post within the survey.
    Nevertheless i do not get it to work.
    Is there a known reason, why this should not work?

    • mm
      ClickDimensions Marketing July 31, 2018 at 10:13 am - Reply

      There’s no reason it should not work – make sure to include the JavaScript that references the window.location.search which will reference the parent window’s URL location. You can also use the debugging tools in your browser to see what JavaScript is not working for you.

Leave A Comment