Auto-submitting a form for Known Visitors | Community
Skip to main content
SanfordWhiteman
New Participant
December 7, 2018

Auto-submitting a form for Known Visitors

  • December 7, 2018
  • 13 replies
  • 12738 views

Marketo's Known Visitor HTML (If Known Visitor, Show Custom HTML in Form Editor » Settings) feature is the obvious answer to a few questions:

 

  • How can I completely ungate an asset no form fillout at all, just a redirect if a web session is is already associated with a known person in my instance?
  • How can I show just a Download button if a session is already associated?
  • How can I auto-submit a form if a session is associated, so I can still switch between the different Advanced Thank You pages in my form setup?

 

Just redirect

This first one is easy: put a <script> that calls location.redirect in your KV HTML. (You do have to manage the redirect URL in JavaScript; it won't use the Thank You URL(s) as you're skipping the form post entirely.)

 

Just a button

The second one is straightforward, too.[1] In the Rich Text editor that pops up when you select Custom HTML, strip everything but the built-in {{form.Button}} token:

 

ss

ss

 

Auto-submit for Known Visitors

The third goal above isn't as easy as you'd expect. If you've dabbled in the Forms 2.0 JS API before, you might think you could do this (purposely screenshot-only so you're not tempted to copy it):

 

ss

 

Nope, that won't work!

 

The reason is a classic bug-you-eventually-round-up-to-intentional: the JS API is not fully supported in KV HTML mode.

 

The whenReady listener itself runs, and the onSuccess event fires... but neither the onSubmit  event, nor calling submit on the form object, will work.

 

So we need to go back to the old-school method of simulating a click event on the button. It works just fine in all browsers, even if primitive:

 

ss

 

Copypasta:

{{form.Button:default=Auto-submit}} <script> MktoForms2.whenReady(function(form){ var formEl = form.getFormElem()[0], submitEl = formEl.querySelector(".mktoButton"); submitEl.click(); }); </script>

 

 

 

Notes

[1] KV HTML does have an unexpected hidden field autofill (i.e. UTM tracking) gap that relates to the 2nd and 3rd bullets equally, but that's separate enough to be covered in another upcoming post.

13 replies

Dilusha_DeTisse
New Participant
July 19, 2019

Hi Stanford,

Thank you for this post. I am very new to Marketo and I am trying to create a blind form for a know visitor. My use case is, when a webinar non-attendee access the reply link in a follow up email (replay link hosted in Wistia), I like to set up a blind form submit saying they viewed the replay. I am not a HTML person and trying to see how I can get the custom HTML code for this purpose. I have also seen this type of code in other articles here in Marketo, but not sure if I need to populate any unique form ID on it. Hoping you can help me figure this piece out.

New Participant
February 8, 2019

Thank you for this post @Sanford Whiteman​

Paul_Johnson
New Participant
January 18, 2019

@Sanford Whiteman , this is one of my favorite recent pieces. Thank you!