SOLVED

Form within a form pre-fill

Go to solution
Khyra
Level 3

Form within a form pre-fill

I have an English preferences center form (form 1) that has pre-fill enabled and is behaving as it should. On this same form, I link to the French version of the preferences center form (form 2) and when you click to access form 2, there is no pre-fill. Does anyone know how to have the pre-fill from form 1 carry over to form 2?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Form within a form pre-fill

You need to attach the original mkt_tok value to the link. Marketo’s default Pre-Fill relies on the mkt_tok.

 

e.g.

MktoForms2.whenReady(function(mktoForm){
  let formEl = mktoForm.getFormElem()[0],
      frenchVersionLink = formEl.querySelector("a#page-french");
frenchVersionLink.search += ( frenchVersionLink.search ? "&" : "" ) + "mkt_tok=" + window.__mktTokVal;
});

 

Where the link has the corresponding id:

<a id="page-french" href="https://lp.example.com/preferences-french.html">Visiter page...</a>

 

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Form within a form pre-fill

We’re lacking some detail here. When you say you “link” to the French version, is that another LP under a different private domain? What exactly does the “link” entail?

Khyra
Level 3

Re: Form within a form pre-fill

Thanks for the prompt reply! Let me try and re-word: form 1 is my English facing preferences center used on Marketo LP 1. Within this English preferences center, there is a CTA which redirects to the French facing preferences center, which is form 2 hosted on Marketo LP 2. Both forms have pre-fill enabled. I want to know if its possible to have the pre-fill info from form/ Marketo LP 1 carry over to form/Marketo LP 2 when you click through?

form/LP 1

Screen Shot 2022-07-13 at 4.14.43 PM.png

Screen Shot 2022-07-13 at 4.17.19 PM.png

form/LP 2

Screen Shot 2022-07-13 at 4.13.52 PM.png

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Form within a form pre-fill

You need to attach the original mkt_tok value to the link. Marketo’s default Pre-Fill relies on the mkt_tok.

 

e.g.

MktoForms2.whenReady(function(mktoForm){
  let formEl = mktoForm.getFormElem()[0],
      frenchVersionLink = formEl.querySelector("a#page-french");
frenchVersionLink.search += ( frenchVersionLink.search ? "&" : "" ) + "mkt_tok=" + window.__mktTokVal;
});

 

Where the link has the corresponding id:

<a id="page-french" href="https://lp.example.com/preferences-french.html">Visiter page...</a>

 

Khyra
Level 3

Re: Form within a form pre-fill

Thanks, that's very helpful! Am I pasting the below as is in the HTML source editor or editing the form's custom CSS?

 

MktoForms2.whenReady(function(mktoForm){
  let formEl = mktoForm.getFormElem()[0],
      frenchVersionLink = formEl.querySelector("a#page-french");
frenchVersionLink.search += ( frenchVersionLink.search ? "&" : "" ) + "mkt_tok=" + window.__mktTokVal;
});

Which elements within this code am I replacing with my French LP url?

SanfordWhiteman
Level 10 - Community Moderator

Re: Form within a form pre-fill


Thanks, that's very helpful! Am I pasting the below as is in the HTML source editor or editing the form's custom CSS?

Neither. This code would go in a separate <script> tag, after the form embed code. On a Marketo LP, that means just before the closing </body> tag.

 


Which elements within this code am I replacing with my French LP url?

You don’t put the LP URL itself anywhere in the code. But the expectation is your <a> tag that links to the French LP has a known id attribute, like

<a id="page-french" href="https://pages.example.com/french.html">go elsewhere</a>

That’s how the code knows what link to update. It does not need to know the URL.