menu

Get More Out of Your Lead Forms

Jan 30, 2024 by Jason McKinney

Tips

As an agency that specializes in web-to-lead sites, we pride ourselves on building well-constructed funnels that result in high quality leads. But what if a lead form could include more information that could help rank the lead or even help an associate convert the lead?

Any action taken by a user on your site can generate a variable that can be stored in local storage and then passed along in a lead form. Most of this can be accomplished using two simple JS functions.

In the following example, we will show a sample use case in which a web site user has completed a survey and has then submitted a lead form.

First, we'll create a function that will write a value to local storage. In this case, we'll store a message that will provide information that we can pass to our lead form:

                    
                    /* Write to local storage */
let score = 10;

function surveyQualifier() {
  if (score >= 10) {
    localStorage.setItem('surveyScore', 'pass');
   } else {
    localStorage.setItem('surveyScore', 'fail');
   }
}
                    
                    

Above, we're using a score from a previously completed survey. We've set the word "pass" or "fail" according to the score and wrote that variable ("surveyScore") to local storage where it will remain for the users session. We run this function when the survey is completed.

Now, let pull it back out of local storage and move it into a hidden field in our form:

                    
                    /* Add value to form field */

function surveyRetrieval() {
  var name = localStorage.getItem('surveyScore');
  if (name != "undefined" || name != "null") {
    // surveyField is the hidden field name
    document.getElementsByName("surveyField")[0].value = name;
  }
}
                    
                    

In the function above, we find out if the variable exists and if it does, we add it to a hidden field in our lead form called "surveyField".

Here's a demo of this code in action:

As you can see from the example above, this extra piece of information about a users behavior can be used to help rank a lead as more or less qualified.


Hope this helps you get more out of your lead forms. Please leave any comments or questions below.

Disclaimer: If the code above is passing along user behavior and linking that to personally identifiable information, please make sure your privacy policy covers this before implementing.