Autofill in Form lightbox | Community
Skip to main content
Level 2
October 15, 2024
Solved

Autofill in Form lightbox

  • October 15, 2024
  • 1 reply
  • 1683 views

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. 

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

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).

1 reply

SanfordWhiteman
Level 10
October 15, 2024

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.

Level 2
October 15, 2024

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
SanfordWhitemanAccepted solution
Level 10
October 15, 2024

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).