Re: Blind Form Submissions for Website

Anonymous
Not applicable

Hi there,

I was wondering if anyone have any suggestions on implementing blind form submissions for a few of our web pages.

The main idea is:

Buttons gets clicked > Form submits if cookie is recognized / form shows if it's an unrecognized cookie > Directs to the content page

Thank you!

Best,

Gina

12 REPLIES 12
Anonymous
Not applicable

We were able to get what we want by adding a JS block on the iframe/landing page. If fields are not empty (our fields are set to autofill), then it will redirect to the follow-up page; else, the form will load.

SanfordWhiteman
Level 10 - Community Moderator

I assume this is a Marketo-hosted LP.  Otherwise, from your brief description, you probably have a race condition causing the code to only work some of the time. 

Anonymous
Not applicable

Yes, it's a Marketo-hosted LP with the script attached to it.

Below's the sample script we used:

<html>

  <head>

  <script type = "text/javascript">

  MktoForms2.whenReady(function (form) {

  // Put your code that uses the form object here

  var email = document.getElementById('Email').value;

  var first_name = document.getElementById('FirstName').value;

  var last_name = document.getElementById('LastName').value;

  var company = document.getElementById('Company').value;

  var image = document.getElementById('loading_gif');

  var form = MktoForms2.getForm(####);

  form.onSuccess(function (values, followUpUrl)

  { window.top.location.href = followUpUrl; return false;

  });

  if (email != "" && first_name != "" && last_name != "" && company != "")

  {

  form.getFormElem().hide();

  document.getElementById('loading_gif').style.display = "block";

  form.submit();

  }

  else

  {

  }

  });

  </script>

  </head>

  <body>

  <img id='loading_gif' src="image_url" style="display: none;">

  </body>

</html>

SanfordWhiteman
Level 10 - Community Moderator

The code looks safe as far as race conditions, since you're using the Forms 2.0 API. But it's making unnecessary (and theoretically risky, though not in the present 2.0 release) use of document.getElementById. It should use form.getValues().Email, etc.

Anonymous
Not applicable

Thanks everyone for the input. I'll discuss with my supervisor and see what is the best way to implement this.

John_Clark1
Level 10

Ahh, I see.

The form will always show, as there's no way to automatically submit it.  The lead will have to click the button even if they're a known lead, but it makes it so they don't have to fill in all of their information again.

John

John_Clark1
Level 10

Hi Gina,

I think this is what you're looking for.

Show Custom HTML Form for Known Leads - Marketo Docs - Product Docs

Basically, if the lead is known (recognized cookie) then they'll be able to click right through.  If not, then they'll be presented with a form.

John

Anonymous
Not applicable

Thanks, John.

I was aware of that form capability, but it didn't redirect me to the next page when the user was recognized and the form was hidden.

Perhaps there is a script I need to add to automatically submit when the form is hidden? This is the part where I got stuck.

SanfordWhiteman
Level 10 - Community Moderator

In fact the Known Lead HTML can be leveraged to forward to the Follow Up URL quite easily.

For the Known Lead HTML, type:

<script>

  document.location = 'http://example.com/your-thank-you-url.html';

</script>

Anonymous
Not applicable

Thanks, Sanford. This seem to work in sending it to the follow-up page, but is there a way to submit the form (if it shows up for the known visitor) automatically?

SanfordWhiteman
Level 10 - Community Moderator

I'm not exactly clear on why you'd want to submit a form that (in this case, by definition) has no new data.  You can accomplish the same tracking (with no wear-and-tear) by appending to the query string of your Thank You URL something like ?from=knownLead.

Grégoire_Miche2
Level 10

Indeed, the "Know user" feature does not bring you to the next page. It enables you to get the content or a link to the next page.

To do it exactly the way you want, you will need some scripting using the forms 2.0 API : Forms 2.0 » Marketo Developers

-Greg