SOLVED

Getting field value client side on page

Go to solution
Erik_Heldebro2
Level 8

Getting field value client side on page

I'm interested in seeing if there's a clear solution for this.

Scenario

Let's say I have a thank you page (Marketo Landing Page) that a lead visits upon filling out a Marketo form.

When filling out the form, Marketo sends a request to backend via Webhooks and maps a response attribute to a custom field.

Having put a middle landing page in the middle with a meta tag for redirecting to the thank you page after about 4 seconds, it still is not quick enough for Marketo to get the value in response to the webhook.

Question

Would it be possible to (1) get the field value client side on the Landing Page once the value exists (not empty), (2) without reloading the page?

For example, checking every 3 seconds until the value is there.

I'm assuming this could be done, tried searching it up but didn't have any luck. Would be interesting to hear any suggestions!

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Getting field value client side on page

Yep, 4 seconds definitely ain't gonna cut it.  Even in an otherwise humming-along instance you might wait 30s.

If you're willing to give the people a spinner for up to 30s (you have to be prepared to give the "looking up your profile is taking longer than usual" type of error if it exceeds a set amount of time) use the same method used on this Lead Field Lookup Form​. That particular form retries 10 times, 1 second apart, since it's only waiting for the session to be associated in order to read a lead field. In your case, you have to wait not only for session association, but for the webhook to have fired and to have written the webhook-served updates back to the database, so I wouldn't even start checking for 5s, though you can tell the end user you started immediately!

Naturally, the other way to do it is to call the remote service from the page itself -- only if security permits. You can let Marketo call it as well, but you don't have to worry about polling for a response this way. In saying you can run it twice, I'm assuming of course the webhook call is idempotent and doesn't cost you anything per call.  You haven't explained what it does, so I can't know....

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Getting field value client side on page

Yep, 4 seconds definitely ain't gonna cut it.  Even in an otherwise humming-along instance you might wait 30s.

If you're willing to give the people a spinner for up to 30s (you have to be prepared to give the "looking up your profile is taking longer than usual" type of error if it exceeds a set amount of time) use the same method used on this Lead Field Lookup Form​. That particular form retries 10 times, 1 second apart, since it's only waiting for the session to be associated in order to read a lead field. In your case, you have to wait not only for session association, but for the webhook to have fired and to have written the webhook-served updates back to the database, so I wouldn't even start checking for 5s, though you can tell the end user you started immediately!

Naturally, the other way to do it is to call the remote service from the page itself -- only if security permits. You can let Marketo call it as well, but you don't have to worry about polling for a response this way. In saying you can run it twice, I'm assuming of course the webhook call is idempotent and doesn't cost you anything per call.  You haven't explained what it does, so I can't know....

Erik_Heldebro2
Level 8

Re: Getting field value client side on page

Thanks Sanford, was hoping to hear from you.

Well this process was connected to our trial sign-up, which could get remade later, I just wanted to see if there was a nifty solution on landing pages. Since the call goes to our backend I'd prefer doing the request via Webhooks.

I used a header with something like <meta http-equiv="refresh" content="15;url=confirmation"> with tokens/default values, so that after a minute at most it will change the refresh url to a static thank you page and stop reloading the page.

Thanks for the advice and help!