SOLVED

Is it possible to prefill a checkbox on a form using a tokens or scripts?

Go to solution
B-Marketo
Level 1

Is it possible to prefill a checkbox on a form using a tokens or scripts?

Hi everyone, we have a issue that needs your help:
we want to be able to prefill checkbox field on a 2nd LP.
flow:
click Email- LP1 (with a form) prefill works via marketo token - LP2 form continuation (with checkboxes for area of interest , prefill not working)

the Mtk token lost tracking on 2nd page .
Marketo suggests:
"There may be a way to add the tracking script to the page with iframe and custom code. However, this would be a custom implementation and Support will not be able to assist in the set up or troubleshooting of this method."

does anyone know what code /script that can be added to prefill for the 2nd page as well please.

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Is it possible to prefill a checkbox on a form using a tokens or scripts?

The question really doesn't have to do with checkboxes specifically. Sounds like you're asking how to forward the original page's mkt_tok to the next page.

 

MktoForms2.whenReady(function(mktoForm){
   mktoForm.onSuccess(function(submittedValues,originalThankYouHref){
      let thankYouUrl = new URL(originalThankYouHref);      
      
      thankYouUrl.searchParams.set("mkt_tok", window.__mktTokVal);
      document.location.href = thankYouUrl.href;
      
      return false;
   })
})

 

 

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Is it possible to prefill a checkbox on a form using a tokens or scripts?

The question really doesn't have to do with checkboxes specifically. Sounds like you're asking how to forward the original page's mkt_tok to the next page.

 

MktoForms2.whenReady(function(mktoForm){
   mktoForm.onSuccess(function(submittedValues,originalThankYouHref){
      let thankYouUrl = new URL(originalThankYouHref);      
      
      thankYouUrl.searchParams.set("mkt_tok", window.__mktTokVal);
      document.location.href = thankYouUrl.href;
      
      return false;
   })
})

 

 

B-Marketo
Level 1

Re: Is it possible to prefill a checkbox on a form using a tokens or scripts?

Hi @SanfordWhiteman , i really appreciate the above, you are correct the aim is the track MKT on the 2nd LP.
when i added the the code to the LP header , code was showing up on the LP(Image attached) , now if i add the code with script tag to the form setting the code don't show as above.
The 2nd LP only works when you refresh the 2nd LP page, or fill the form close it and fill it again, so seems like the cookies are being tracked? for the form and MKT still not working please, can you confirm where i need to add the code and if script tags are needed.
I have also tried script tag on the page and same result only works with cookies from pre-fill or refreshed page :

<script>// <![CDATA[

MktoForms2.whenReady(function(mktoForm){

   mktoForm.onSuccess(function(submittedValues,originalThankYouHref){

      let thankYouUrl = new URL(originalThankYouHref);     

      

      thankYouUrl.searchParams.set("mkt_tok", window.__mktTokVal);

      document.location.href = thankYouUrl.href;

     

      return false;

   })

})

// ]]></script>

BMarketo_0-1674477023027.png