Form not pre-filling reliably | Community
Skip to main content
Kai_Crow2
Level 2
June 22, 2018
Question

Form not pre-filling reliably

  • June 22, 2018
  • 2 replies
  • 5496 views

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)

2 replies

SanfordWhiteman
Level 10
June 22, 2018

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
Kai_Crow2Author
Level 2
June 22, 2018

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
June 22, 2018

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.

SanfordWhiteman
Level 10
June 22, 2018

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
Kai_Crow2Author
Level 2
June 22, 2018

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?