SOLVED

Re: Hiding forms for known visitors, but still requiring some fields

Go to solution
Jack_Wildt
Level 2

Hi everyone, this is an extension of this question - Hiding forms for known visitors, but still requiring some fields.

I have embedded a second form into the custom HTML that show to know visitors on the first form. The problem is that progressive profiling is not working on this second form, it asks for every field. Is there some javascript that I can use to fill in the fields we already have for the visitor?

Thanks!

Tags (1)
1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

Above the call to loadForm() in the embed code, insert this code:

mktoPreFillFields.filledFields = Object

  .keys(mktoPreFillFields)

  .filter(function(field){

    return mktoPreFillFields[field] != "null";

  });

View solution in original post

13 REPLIES 13
SanfordWhiteman
Level 10 - Community Moderator

What's your URL?

And do you mean Progressive Profiling or Pre-Fill (ProgPro doesn't "fill in" fields, it hides fields that either have a value or are greater than your ProgPro max displayed fields setting).

Jack_Wildt
Level 2

Progressive profiling. I only want it to show the field(s) we need to collect.

SanfordWhiteman
Level 10 - Community Moderator

Above the call to loadForm() in the embed code, insert this code:

mktoPreFillFields.filledFields = Object

  .keys(mktoPreFillFields)

  .filter(function(field){

    return mktoPreFillFields[field] != "null";

  });

Jack_Wildt
Level 2

This works great! Thank you very much Sanford.

SanfordWhiteman
Level 10 - Community Moderator

Cool, you actually caught an interesting bug/exceptional situation but not worth an official fix.

Jack_Wildt
Level 2

There is actually one hiccup in this, in that you can still submit the form even if the embedded form is missing a required field.

SanfordWhiteman
Level 10 - Community Moderator

That's not related to the ProgPro, though.

That's happening because you aren't showing the right Submit button for the embedded form (not sure why you did this).

Jack_Wildt
Level 2

Ah, gotcha. It is what they suggested in the previous thread. I am not sure how to fix having two buttons without hiding the second one.

SanfordWhiteman
Level 10 - Community Moderator

Hide the default one that comes with the Known Lead HTML. That one is linked to the (invisible) first form. You want the one that comes with the second, visible form.

Jack_Wildt
Level 2

Sorry to keep asking for things, I really appreciate your help. I am having issues getting the embedded form to lead to the correct confirmation page. I can get it to point to outside urls, but we define the confirmation page using a token, {{my.LPConfirmationPage}}. This is the code I am using.

<span style="color: #ffffff;">Welcome back, {{lead.FirstName}} {{lead.LastName}}</span><br /><span style="color: #ffffff;">{{form.NotYou:default=Not you?}}</span><br /><br />

<script src="//app-ab09.marketo.com/js/forms2/js/forms2.min.js"></script>

<form id="mktoForm_1273"></form>

<script>// <![CDATA[

mktoPreFillFields.filledFields = Object 

  .keys(mktoPreFillFields) 

  .filter(function(field){ 

    return mktoPreFillFields[field] != "null"; 

  });

MktoForms2.loadForm("//app-ab09.marketo.com", "848-AHN-047", 1273, function(form){

form.onSuccess(function(values, followUpUrl) {

location.href = {{my.LPConfirmationPage}};

return false;

});

});

// ]]></script>

SanfordWhiteman
Level 10 - Community Moderator

You can't use the token there.

I'd pull the onSuccess() out of the Known Lead HTML. Just have that in the page on its own:

MktoForms2.whenReady(function(form){ 

  form.onSuccess(function(values, followUpUrl) { 

    location.href = {{my.LPConfirmationPage}}; 

    return false

  }); 

});

In the Known Lead HTML, skip the last argument to loadForm():

MktoForms2.loadForm("//app-ab09.marketo.com", "848-AHN-047", 1273)

Jack_Wildt
Level 2

Oh duh, I should have thought about that.

Thank you so much!

Jack_Wildt
Level 2