Re: Form submission due to data field // Request Double Opt In before redirect to Thank you page // associate Lead befor end of Form.onsuccess

WolframLotz
Level 4

Form submission due to data field // Request Double Opt In before redirect to Thank you page // associate Lead befor end of Form.onsuccess

Hi everyone, 
for marketing consents we use a doulbe opt in process. We have some content we want to show a visitor only in case he has already a valid double optin. 
Importend: It's about a non-Marketo Landingpage

My current concept is something like:

  • Add a marketo form in a non-Marketo Landingpage (with own JS)
  • When form is send:
    • Add an invisible iFrame to the page pointing to a Marketo landingpage
    • The LP in the iFrame uses Tokens to send data to the main page 
    • Handle the data in JS to find out if the user already has a double opt in. 
      • If yes - forward the user to the thank you page
      • If no - show a corresponding message. (The form sumit itself started the DOI process in that case


What's the issue:

  • I start the process IN mktoForm.onsuccess
  • The iFrame shows the data for the current associated lead
  • But the association is finished just AFTER mktoForm.onsuccess

 

Unfortunately the associateLead feature isn't supported anymore. 

Do you have an idea how to call the iFrame aka. Data Transfere Page kind of "mktoForm.AFTERSuccess"? 
Or do you have an idea how to associate the lead before sending the form?
(Currently the only idea I'd have would be to send another form in between but I hope for an easier less complex solution.)

Best Regards
Wolfram

8 REPLIES 8
EllenSchwier
Level 4

Re: Form submission due to data field // Request Double Opt In before redirect to Thank you page // associate Lead befor end of Form.onsuccess

I think another way to do this would be to:

1. Add a hidden field for "double-opt-in" with the true/false value populated from Marketo. You will need to make sure pre-fill is enabled on the field.

2. Add a choice step in the Settings of the form to determine where someone is sent upon form completion. If double opt-in is true, go to thank you page. If it is false, send them to the other landing page with a second form to request double opt-in. 

And then simply use the Marketo form embedded on your external website. 

Good luck with your project!

SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission due to data field // Request Double Opt In before redirect to Thank you page // associate Lead befor end of Form.onsuccess


1. Add a hidden field for "double-opt-in" with the true/false value populated from Marketo. You will need to make sure pre-fill is enabled on the field.

But that wouldnโ€™t meet the requirement, as you canโ€™t Pre-fill if thereโ€™s no existing associated session.

 

The idea here is that the session is anonymous until the person fills out the form.

 

EllenSchwier
Level 4

Re: Form submission due to data field // Request Double Opt In before redirect to Thank you page // associate Lead befor end of Form.onsuccess

Ah, that makes sense, thank you @SanfordWhiteman.  

SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission due to data field // Request Double Opt In before redirect to Thank you page // associate Lead befor end of Form.onsuccess


Unfortunately the associateLead feature isn't supported anymore.

associateLead was asychronous anyway, it wouldnโ€™t have helped.

 

The way to accomplish this is to poll the DTP on a timer within the onSuccess, until the Email Address that was just submitted appears in the response. Then you know you have that personโ€™s values and can perform the next set of actions. return false; from the main onSuccess function and the immediate redirect is disabled. Then you have control over when/if/how the redirect occurs.

 

 

WolframLotz
Level 4

Re: Form submission due to data field // Request Double Opt In before redirect to Thank you page // associate Lead befor end of Form.onsuccess

Good point.

WolframLotz
Level 4

Re: Form submission due to data field // Request Double Opt In before redirect to Thank you page // associate Lead befor end of Form.onsuccess

@EllenSchwier  and @SanfordWhiteman 
Thank you. I figured it out. It was not the flow but the timing. 


OnSuccess is already defined as "It happens after the submit but before the redirect". My issue was that Marketo just needs some time to associate the user after the form submit. 
So if you wait e. g. 1-2 seconds so association happend and you can access the data. 

Currently I use something like setTimeout(() => {form.submit();;},1000); before I starte the process.

For the moment it's working. Admitted it's not really elegant but functional. As I have to wait for processes in several moment (e. g. in case the Munchkin cookie was not already set). So the whole process can take some seconds. 

If any of you has an idea how to solve this more elegent and performant I'd really thankful. ๐Ÿ™‚

Best regards 
Wolfram

SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission due to data field // Request Double Opt In before redirect to Thank you page // associate Lead befor end of Form.onsuccess


So if you wait e. g. 1-2 seconds so association happend and you can access the data.

But thatโ€™s not actually accurate. Youโ€™re just guessing about 1-2 seconds. Thatโ€™s why the right way is to poll every N milliseconds (I usually use 200ms) for a max number seconds (I use 10s).

 

While thereโ€™s no built-in event to trigger on, polling repeatedly is the accurate way to detect association.

WolframLotz
Level 4

Re: Form submission due to data field // Request Double Opt In before redirect to Thank you page // associate Lead befor end of Form.onsuccess

Hi Sanford, 
you are absolutely right. It's not accurate. As you say. It's just a guess. And a conclusion by try and error. 
Till now I unfortunately I hadn't the right idea how to check it the best way. In case it's a new user It should be easy as I can compare the give and the delivered email address. But in case of a know user I don't see any option to compare if the deliverd state is the actual state or the state before sending the form. 

Or do you have an idea how to figure out if the form submission was already processed on marketo side?