Skip to main content
Mike_Roberts2
Level 2
March 12, 2018
Question

Autofill email field via URL

  • March 12, 2018
  • 2 replies
  • 4776 views

Not sure how to explain this but here goes:

We're currently using an email sign-up method that requests the email address on a page then fills it in on the actual form field using the following:

URL?email=test@test.com

When submitted the browser opens the actual form and the email is automatically filled in and the user must fill in the rest of the form.

We're testing using a Marketo form instead so I'm wondering if there's a similar syntax?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Josh_Hill13
Level 10
March 12, 2018

images?

why are you doing this?

Mike_Roberts2
Level 2
March 12, 2018

^ This box is on the page. The user enters their email and then hits submit.

^ This is the form the submit button takes you to. See the email is already filled in the field.

In the interest of not derailing the purpose of this thread, I'm not going to go into why. I appreciate your interest in helping tho, Josh.

SanfordWhiteman
Level 10
March 12, 2018

MktoForms2.whenReady(function(form){

  form.setValues({ Email : decodeURIComponent(document.location.search.substring(1)) });

});

Put this is in a <script> anywhere after the <script> that loads forms2.min.js.

This assumes the entire querystring is the email address. If there are other query parameters as well, the code is more complex.

Level 2
May 15, 2019

Thanks for this!
Helped me to populate the autofill for my unsubscribe.