Form not pre-filling reliably

Kai_Crow2
Level 2

We've just setup a process using two forms to collect data in two parts:

1) collect email address on initial submission via an embedded mkto form on our home page

2) collect a few further details on a mkto landing page with a form (user is directed to the lading page via the success action of the embedded form)

*Most of the time, this works well - they arrive at the form on the landing page with email pre-filled and the other fields needing completion. However, every so often, the email field is not pre-filled. In those cases, if you immediately refresh the page, it is then pre-filled. Seems to me like sometimes the page is loading too quickly and the pre-fill is failing, or something like that? But then I've never seen this happen on another landing page, so wondering if this is something to do with passing between the embedded form and the mkto landing page.

Anyone else noticed a similar issue? Any ideas on a work around?

At the moment I'm thinking the best option is to use a javascript to reload the page once to ensure the pre-fill is completed

Try it yourself if you want:

NPS Software - Real time Customer Feedback | AskNicely

(form is the get a demo one on the first screen)

26 REPLIES 26
SanfordWhiteman
Level 10 - Community Moderator

You should also read this post related to the same feature: https://blog.teknkl.com/dont-call-a-marketo-lp-an-external-url/

Kai_Crow2
Level 2

So if I'm understanding correctly, then my first setup should have worked fine - form 1 had the follow-up (yes, I wish they'd be consistent with naming) action set to a marketo landing page (the one that lives at https://get.asknicely.com/demo-booking.html ). Am I understanding correctly that then the built in behaviour of the marketo landing page should be if the association hasn't been completed, then load the data from the aliId parameter? Or would I need to separately setup a fall-back method to use the aliId data?

SanfordWhiteman
Level 10 - Community Moderator

Yes, this is expected behavior. As I responded to someone else earlier today, there is no guarantee that the session cookie will be associated by the next pageview. While association typically only takes a couple of seconds at most, it happens asynchronously not interlocked in any way with the next HTTP request.

Marketo LPs can also read values from a read-your-write cache, designated by the aliId query parameter, instead of from the cookie-associated lead. The aliId would normally would take care of your concerns here, but you're stripping it out on /demo-request-2.html with this piece of code:

   $(document).ready( function() {

      url = "https://get.asknicely.com/demo-booking.html";

      $( location ).attr("href", url);

   });

(Also, $(location).attr("href",<url>) isn't really the way to do this, it's location.href = <url> -- and no, those aren't the same!)

I don't know why you're waiting until .ready (DOMContentLoaded) on the interstitial, but assuming that part is truly necessary, you want this:

   $(document).ready( function() {

      var redirectLoc= document.createElement("a");

      redirectLoc.href = "https://get.asknicely.com/demo-booking.html";

      redirectLoc.search = document.location.search;

      document.location = redirectLoc;

   });

Kai_Crow2
Level 2

Thanks Sanford, good to know this is to be expected.

The js you mention above wasn't actually on the page when I was first experiencing the problem - I added this because in every case where I saw the form not pre-filling, simply re-loading the page the instant it loaded seemed to work, so I figured load page one, then redirect to page two would ensure that the association is complete when the form loads, and it seems to work - run it through 20 times in different browsers and the second page loads with form pre filled every time whereas before, I was seeing every 3rd or 4th page load not pre-filled. From what you're saying, this probably still doesn't guarantee it'll work, but seems much safer than what I was using previously.

Thanks for taking a look. I'll look at the js we're using too.

Cheers,

Kai

SanfordWhiteman
Level 10 - Community Moderator

so I figured load page one, then redirect to page two would ensure that the association is complete when the form loads,

Nope, that wouldn't ensure it... I would never write code that guesses that a process is complete on the back end. You should actually poll for the values if this is the direction you're going.

Also, the aliId should be taking care of you here. I'd like to see the page with the original flow intact.

Kai_Crow2
Level 2

Well, you're welcome to give this a test if you want, but I'm feeling rather silly because having embedded a clone of the form on a new page and changed it back to go straight to the  https://get.asknicely.com/demo-booking.html  landing page, I've tested it 10 times so far and not found the same issue once - it's pre-filling perfectly every time. Leads me to believe that maybe I had entered the URL instead of selecting the landing page the first time around? I'm going to test a few more times then probably switch my live version back if it looks safe.

SanfordWhiteman
Level 10 - Community Moderator

Leads me to believe that maybe I had entered the URL instead of selecting the landing page the first time around

Probably! As in my blog post.

Kai_Crow2
Level 2

Actually, a few more test submissions and I have run into the same issue again with this form - sporadically, it doesn't pre-fill, but then does if the page is reloaded

SanfordWhiteman
Level 10 - Community Moderator

But you're not using the aliId again now -- look in the URL of the Thank You page, if it doesn't have aliId=<integer> then you must not be using the Landing Page option in the form setup.

Kai_Crow2
Level 2

Just double checked - it's definitely set to follow up with landing page:

Screen Shot 2018-06-22 at 3.14.49 PM.png

SanfordWhiteman
Level 10 - Community Moderator

Maybe the form descriptor is corrupt and that's why you aren't getting the aliId now -- but that for sure would cover you, it's pretty much designed for this case.

Maria_Hirschbe1
Level 2

Hello Sanford Whiteman,

We ran into a similar problem and were wondering if you could help.

We have a simple Marketo form with an email address field and a hidden checkbox field with the default value = “True”. After this form is submitted, the person is redirected to another Marketo LP with a form on which this checkbox field is visible and should be selected, and the email address should be pre-populated too. We noticed that sometimes the checkbox is not selected, but the email address is populated. We have the aliId in the url when the person is redirected to the second Marketo page.

How can we pass the hidden value “True” for a field from the first to the second Marketo form?

Thank you

Maria

SanfordWhiteman
Level 10 - Community Moderator

The value should be "yes" (lowercase) actually, not "True" -- that's the canonical way that Booleans are represented on Marketo forms. so when you have a Hidden field (which is a freeform string) it should use the same values.

Maria_Hirschbe1
Level 2

Sanford,

Thank you for your help. I changed the value of the hidden field to "yes" (approved the form and approved the LP), but still sometimes this field is not selected on the second form.

SanfordWhiteman
Level 10 - Community Moderator

Can you reproduce the condition easily?

What does the prefill block contain when it fails/succeeds? If you open your F12 Console and enter

mktoPreFillFields

you'll see an object.  Open up that object to see its properties (esp. the newsletter field) and post a screenshot of failure and success states.

Maria_Hirschbe1
Level 2

Hi Sanford Whiteman​,

Would you be able to point us in the right direction as to which Forms JS API to use to populate the value of the field on the second form based on the value of the hidden field on the first form?

Marketo Support recommended to delay the display of the second form by a few seconds, but it does not sound like a user-friendly solution.

SanfordWhiteman
Level 10 - Community Moderator

Marketo Support recommended to delay the display of the second form by a few seconds, but it does not sound like a user-friendly solution.

Not just non-user-friendly, it's technically wrong. The reason the aliId and the read-your-write cache exists is because this arbitrary wait is not guaranteed to work.

I'd like to take a closer look at your desktop while you're reproducing the failure. It may be browser-specific and, as you know, I need to get a jump on forms bugs and fixes.

Maria_Hirschbe1
Level 2

Sanford,

It takes me 3-5 attempts to reproduce.

On success, the value is "bain_optinnewsletterbaininsights":true; on failure, it is "bain_optinnewsletterbaininsights":null.

This is the hidden field:

Maria

SanfordWhiteman
Level 10 - Community Moderator

What is/are the URLs here?

Maria_Hirschbe1
Level 2

Hi Sanford,

Here is the url: http://go.bain.com/test-email-address-form-1.html

We expect the "Bain Insights newsletter" to be selected on the second page.