SOLVED

Autofill in Form lightbox

Go to solution
JayNGravel
Level 2

Autofill in Form lightbox

Hi,

I've added Marketo form lightbox code to a Marketo landing page, but when I access the page from a live email (not a test email), the form doesn't prefill with my data. Here’s what I’ve observed:

  • Form prefill is enabled at the field level.
  • The form opens in a lightbox when the landing page loads.
  • Prefill works when the form is inline with the landing page but not in the lightbox.
  • I've also tried opening the page in an incognito browser.

Any insights on why this might be happening? Please suggest. 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Autofill in Form lightbox

Well, like I said above, you can’t use the embed code, which is what you’re doing here. You need to use a proper named <div class="mktoForm" id="unique_id" mktoName="Friendly name in LP Editor"> and choose the form in LP Editor. That’s the only way Marketo knows there’s a form on the page to Pre-Fill from the back end at the time the page is rendered on the server. Otherwise it’s just front-end stuff — Marketo has no idea you’ll be pulling the form embed in at some later.

 

So what you have now is a <div> that’s just treated like any other element, and then you’re using the embed code MktoForms2.loadForm() to render the form. Which works fine but cannot use native Pre-Fill (it could, to be fair, use my non-native SimpleDTO JS to Pre-Fill, but I prefer not to recommend that method unless you know why you need it).

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: Autofill in Form lightbox

Pre-Fill and Autofill are different.

 

Pre-fill fills hidden or visible fields from the Marketo database for known leads. Autofill fills hidden fields from query params or cookies. So you meant “Pre-fill” in the subject line.

 

Anyway, are you using a named Marketo form on your template (i.e. <div class="mktoForm">) in both cases? This is required for native Pre-Fill; you can’t use the form embed.

JayNGravel
Level 2

Re: Autofill in Form lightbox

Thank you for replying.

Yes, I need to pre-fill the form with data from the Marketo database for known leads when they click the landing page URL from an email. I added the following code to my Marketo landing page to open the form in a lightbox upon page load, but it's not pre-filling as expected.

<div class="mktoForm">
    <form id="mktoForm_9898"></form>
</div>
<script>MktoForms2.loadForm("marketo_url", "marketo_id", 9898, function (form){MktoForms2.lightbox(form).show();});</script>

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Autofill in Form lightbox

Well, like I said above, you can’t use the embed code, which is what you’re doing here. You need to use a proper named <div class="mktoForm" id="unique_id" mktoName="Friendly name in LP Editor"> and choose the form in LP Editor. That’s the only way Marketo knows there’s a form on the page to Pre-Fill from the back end at the time the page is rendered on the server. Otherwise it’s just front-end stuff — Marketo has no idea you’ll be pulling the form embed in at some later.

 

So what you have now is a <div> that’s just treated like any other element, and then you’re using the embed code MktoForms2.loadForm() to render the form. Which works fine but cannot use native Pre-Fill (it could, to be fair, use my non-native SimpleDTO JS to Pre-Fill, but I prefer not to recommend that method unless you know why you need it).

JayNGravel
Level 2

Re: Autofill in Form lightbox

Thank you @SanfordWhiteman  for the clarification.