Re: Form not pre-filling reliably

Kai_Crow2
Level 2

Form not pre-filling reliably

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

Re: Form not pre-filling reliably

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

Re: Form not pre-filling reliably

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

Re: Form not pre-filling reliably

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

Re: Form not pre-filling reliably

Sure - I'll create an alternate version with the original setup if you want to take a look.

Thanks again for your help!

Kai_Crow2
Level 2

Re: Form not pre-filling reliably

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.

Kai_Crow2
Level 2

Re: Form not pre-filling reliably

Oh and URL with the new form on is: NPS Software - Real time Customer Feedback | AskNicely

SanfordWhiteman
Level 10 - Community Moderator

Re: Form not pre-filling reliably

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

Re: Form not pre-filling reliably

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

Re: Form not pre-filling reliably

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.