alex3
11/15/2017 - 11:39 PM

Grab URL Parameter to prefill form field

Grab's the value of url parameter "employer=" and sets the value into the marketo form field "Company" of the landing page. Also, has encoding special characters.

Example URL: http://resources.glassdoor.com/lp-us-ebook-clone.html?employer=Hewlett%20Packard%20APAC

  MktoForms2.whenReady( function(form) {
     var urlParams   = new URLSearchParams(window.location.search);
	   var employerName = urlParams.get('employer');
     form.vals( {"Company":employerName} );//set value in Employer field
  })