How to Pre-Fill Boolean Fields as Radio Buttons in Forms?

Juhui_Cho
Level 2

How to Pre-Fill Boolean Fields as Radio Buttons in Forms?

Hello,

We want to pre-fill boolean fields in a form and display them as radio buttons on a landing page. However, despite enabling "Form Pre-Fill" at the admin: landing page level and setting the specific field to "Pre-Fill: Enabled" in the form, the radio buttons are not being pre-checked with the stored values.

Below is our test scenario:

  1. A boolean field (e.g., Subscribe_Newsletter) is set up as radio buttons.
  2. The radio button options are:
    • Option 1: Display Value: "Agree", Stored Value: "true"
    • Option 2: Display Value: "Disagree", Stored Value: "false"
  3. If the value of Subscribe_Newsletter is already stored as true in the Marketo database, we expect the "Agree" radio button to be pre-checked when the form loads.

Is there a way to achieve this? We also tried adding a script to handle this, but it still doesn't work.


I’ve read that boolean fields might not support Pre-Fill—could that be the issue?  

 

Any guidance would be greatly appreciated.

 

This post was edited by a moderator for accuracy.

4 REPLIES 4
uditmathur
Level 7 - Community Advisor

Re: How to Pre-Fill Boolean Fields as Radio Buttons in Forms?

HI @Juhui_Cho ,

 

Marketo form pre fill works only on below conditions.

 

Scenario Will the form pre-fill? Notes
Clicking a tracked link in a Marketo email to a Marketo landing page with a form which has pre-fill enabled Yes The email link must have mkt_tok enabled. Links that are not tracked or that have mkt_tok disabled will not work.
Navigating directly to a Marketo landing page with a form which has pre-fill enabled No A direct link to the landing page will not have the mkt_tok present in the HTTP request.
Refreshing a Marketo landing page with a form which has pre-fill enabled No The mkt_tok is stripped from the URL after Marketo Landing Pages load so refreshing the page will not include the mkt_tok in the URL. As a result, pre-fill will not work.
Clicking a link in a sample email to a Marketo landing page with a form which has pre-fill enabled No The sample email will not have a valid mkt_tok attached to the link and so will not pre-fill the form. If you wish to test form pre-fill you will need to use a real email from a Marketo campaign.

Navigating to a non-Marketo page that includes an embedded Marketo form which has pre-fill enabled

No This behavior does not change with the upgrade. Pre-fill has never been supported for Marketo forms that are embedded on non-Marketo pages.
Navigating to a non-Marketo page that includes an <iframe> pointing to a Marketo Landing Page that includes a form with pre-fill enabled With custom implementation The form within the Marketo Landing Page that is being loaded in the <iframe> will pre-fill if the mkt_tok value from the original HTTP request is passed along to the <iframe> URL
Visiting a Marketo page with a mkt_tok that is not associated with the same person record as an existing Marketo Munchkin cookie currently stored on the browser No This will prevent the wrong person’s information from being displayed in cases where a computer is shared, or an email with a mkt_tok tracked link is forwarded to another person that may already be cookied as a known person in your database.
Copying a Marketo tracked link from an email and sharing/pasting it externally (email, blog, chat, social media post, etc.) that enables another individual to click the tracked link Yes The tracked link in a Marketo email will redirect to a URL with the mkt_tok included, so anyone clicking this link will reach a page and see pre-fill data associated with the known person record from the “to” line of the email.
SanfordWhiteman
Level 10 - Community Moderator

Re: How to Pre-Fill Boolean Fields as Radio Buttons in Forms?

@uditmathur the question wasn’t about — or didn’t seem to be about — when Pre-Fill works overall, though. It was specifically about Boolean ↔︎ Radio mapping.

 

Of course if @Juhui_Cho isn’t testing in a setup where Pre-Fill works at all that’s a different case.

SanfordWhiteman
Level 10 - Community Moderator

Re: How to Pre-Fill Boolean Fields as Radio Buttons in Forms?

What you’ve described is simply the default behavior when the db field type is Boolean and the form field type is Radio.

 

It even works when the Boolean is null — that is, neither true nor false — by not choosing either radio.

 

Did you set the field up like this in Form Editor?

SanfordWhiteman_0-1739251068756.png

 

 

 


Is there a way to achieve this? We also tried adding a script to handle this, but it still doesn't work.

(This isn’t specific enough to comment on. You don’t actually need code, as explained above. There are also ways to do it with code, provided it’s the right code.)

 

 


I’ve read that boolean fields might not support Pre-Fill—could that be the issue?

Distressing that anyone would make such a claim. It's completely + provably false. Please link to where you’ve read that.

Juhui_Cho
Level 2

Re: How to Pre-Fill Boolean Fields as Radio Buttons in Forms?

Hello,

@uditmathur, thank you. I tested by adding mkt_tok to the button link in the email, but it seems that mkt_tok might have been lost when navigating to the landing page.

@SanfordWhiteman, thank you. I have configured the values exactly as shown in the image you provided.

To provide more details about our test environment:

  1. We want to ensure that customers do not have to re-enter their email addresses.
    (* However, we do not fully trust email pre-fill based on browser cookies. We found that if a single browser has previously submitted forms with multiple email addresses, even when using mkt_tok in the email link, the form may recognize a previously form submitted email address instead of the one that received the email.)

  2. Therefore, we appended ?email={{lead.Email Address}} as a parameter in the link from the email to the landing page and ensured that mkt_tok was included. (This landing page is only accessible via the email link.)

  3. First landing page: The form contains a hidden Email Address field, which captures the value from the 'email' URL parameter.
    (* If you need a sample page link, I can provide it. It includes the Email Address token value and the mkt_tok value. If you are able to test it, I will send it via a private message due to security concerns!)

  4. Second landing page: Since the email has been identified, we want to pre-fill and display the radio buttons based on the boolean field values currently stored for this email address.

Of course, I have enabled Pre-Fill for the relevant fields in the form, and Form Prefill is also enabled in the Admin > Landing Pages menu.

I suspect that this issue might be occurring because mkt_tok is lost when navigating between landing pages. Would you be able to provide any guidance on this?


Thank you .

(+ Also, I can no longer find the link that mentioned Boolean fields not supporting pre-fill. I believe I came across it while browsing multiple pages, and I may have misunderstood. I apologize for any confusion.)