Can I show options on email preferences form based on boolean fields?

Guitarrista82
Level 6

Can I show options on email preferences form based on boolean fields?

To explain more, we have created an email preferences form (embedded on a Marketo landing page) wherein each selection uses a boolean field:

 

Fields on existing member record:

 

email preferences options.png

 

Fields as selections on Marketo form/landing page:

Guitarrista82_0-1686007505035.png

 

I've scoured through Sandy's blogs on forms on https://blog.teknkl.com/, but did not come across a specific solution for my situ.

Is it possible to show each of the options above only if the corresponding field on an individual member's record is unchecked/false? And/or can the option be shown as checked if it is checked/true on the member's record?

 

Thank you,

LK

 

 

 

12 REPLIES 12
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Can I show options on email preferences form based on boolean fields?

From what I can understand, you need the form pre-fill on your page. Based on the data of the cookied person record, you can either show/hide fields or display the fields with the data prefilled if the person record already has data for that field in the Marketo. Check out Sandy’s form pre-fill solution here.

 

I think you should prefill and show all the fields instead of hiding the ones that have a True value, as if you do so, the person once opted in wouldn’t be able to opt out from the individual categories via this page (unless of course if they clear their cookies or visit from a different browser or system).

Guitarrista82
Level 6

Re: Can I show options on email preferences form based on boolean fields?

Hi @Darshil_Shah1 ,

 

Thanks so much for your response! 

 

I know that there is a Form Prefill setting on Marketo landing pages (see below), but are you saying that I would need to implement the instructions Sandy provided in his blog--that just enabling the Form Prefill option isn't enough?

 

Guitarrista82_0-1686076277284.png

 

Important to note too is that, unlike the first prerequisite in Sandy's blog, we will not be using an external site so there's no need to enable prefill on an external site. We just want to be able to update the form fields on the Marketo landing page itself based on the data on a customer record in Marketo.

Guitarrista82_0-1686077694957.png

 

Thanks again,

LK

 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Can I show options on email preferences form based on boolean fields?

Hi @Guitarrista82,

 

The native form pre fill only works if the lead lands on the landing page by clicking a tracked link from an e-mail, check this post:

https://nation.marketo.com/t5/knowledgebase/form-pre-fill-feature-upgrade/ta-p/251652

 

Sandy’s solution helps getting around this and with it the forms prefill as long as the person is cookied (i.e., munchkin tracking cookie is associated with a known person record in Marketo).

Guitarrista82
Level 6

Re: Can I show options on email preferences form based on boolean fields?

Okay, understood...

 

Please see my additional comment below:

 

Important to note too is that, unlike the first prerequisite in Sandy's blog, we will not be using an external site so there's no need to enable prefill on an external site. We just want to be able to update the form fields on the Marketo landing page itself based on the data on a customer record in Marketo.

Guitarrista82_0-1686077882049.png

 

So then would Sandy's form prefill hack be needed in my case? It sounds like I just need to test out visiting the landing page directly from an email, in this case?

 

Thanks,

LK

 

 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Can I show options on email preferences form based on boolean fields?

Gotcha! The native form prefill does work on clicking a tracked email link to the Marketo LP.

Guitarrista82
Level 6

Re: Can I show options on email preferences form based on boolean fields?

Hi @Darshil_Shah1,

 

Okay, I've run through the process of sending myself a live email containing the link to the landing page with the email subscription options form.

 

I enabled the settings below on the link:

 

Guitarrista82_0-1686089779279.png

 

I sent myself the email via a live campaign (not a test).

 

In Gmail, when I hover over the link to the landing page, the Marketo tracking token does appear, as shown below:

 

email containing link to unsub lp-form.png

 

However, when I click on the link, even in incognito mode, the fields below do not appear checked, even though they are checked on the account to which I sent the email:

 

Results on form on landing page:

Email subscription options.png

 

Corresponding boolean fields on my account record in Marketo:

 

Guitarrista82_1-1686090418427.png

 

Any ideas why the fields are not appearing prefilled on the form even though they're checked on my record?

 

 

Not sure if this would help, but when I did an inspect element on the landing page, I see these errors:

 

Guitarrista82_0-1686090833975.png

Guitarrista82_2-1686090863375.png

 

 

Thanks,

LK

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Can I show options on email preferences form based on boolean fields?

Do you have any custom JS on your landing page? When you opened the tracked link from an email, did you see the mkt_tok query parameter added at the end of the Marketo LP URL?

Guitarrista82
Level 6

Re: Can I show options on email preferences form based on boolean fields?

Hi @Darshil_Shah1

 

Actually, the issue was I had to clear the cache, then the prefill appeared.

However, a new issue has come up where, let's say someone just checks all the boxes to subscribe to the emails, but doesn't uncheck the unsubscribe box. This affects our automation processes that send API calls to an outside website that updates the contacts' subscription statuses. 

 

It would be helpful if, when someone checks any of the email subscription boxes, the unsubscribe box was automatically unchecked. Or if they checked "unsubscribe", the email boxes would be automatically unchecked.

 

I saw a few discussions in the Community that provided javascript to make this happen, but I'm not sure which ones would actually work.

For reference, here's one that I thought might work (after replacing the values with our values):

 

<script>
    //Written by Diederik Martens (C) 2014
    MktoForms2.whenReady(function (form){
        //check for unsubscribe at any change
        form.onSubmit(function(){
            //get the form field values
            var vals = form.vals();
            //if all unchecked > unsubscribe
            if(vals.ePCNews == "No" && vals.ePCEvents == "No" && vals.ePCContent == "No" && vals.ePCLogistics == "No" && vals.ePCProduction == "No" && vals.ePCWorkforce == "No" && vals.ePCSCPO == "No" && vals.ePCSOP == "No") {
                form.vals({"Unsubscribed":"true"});
                form.vals({"Email_Opt_in__c":"false"});    
            } else {
            //something (type or topic) is still checked so we keep opt-in
                //any of the 3 types is still checked
                if(vals.ePCNews == "Yes" || vals.ePCEvents == "Yes" || vals.ePCContent == "Yes") {
                    //check if any topic is also check
                    if(vals.ePCLogistics == "Yes" || vals.ePCProduction == "Yes" || vals.ePCWorkforce == "Yes" || vals.ePCSCPO == "Yes" || vals.ePCSOP == "Yes") {
                        //at least 1 topic is checked so don't interfere. but do record optin
                        form.vals({"Unsubscribed":"false"});
                        form.vals({"Email_Opt_in__c":"true"});    
                    } else {
                        //none of the topics are checked, whilist at least 1 type is checked. so check all topics by default
                        form.vals({"Unsubscribed":"false"});
                        form.vals({"Email_Opt_in__c":"true"});    
                        form.vals({"ePCLogistics":"Yes"});
                        form.vals({"ePCProduction":"Yes"});
                        form.vals({"ePCSCPO":"Yes"});
                        form.vals({"ePCSOP":"Yes"});
                        form.vals({"ePCWorkforce":"Yes"});                        
                    }
                }
                //none of the 3 types are checked
                else {
                    //check if any topic is checked.
                    if(vals.ePCLogistics == "Yes" || vals.ePCProduction == "Yes" || vals.ePCWorkforce == "Yes" || vals.ePCSCPO == "Yes" || vals.ePCSOP == "Yes") {
                        //at least 1 topic is checked, whilist no type is checked, lets keep the person opt-in, but which type to check? check all.
                        form.vals({"Unsubscribed":"false"});
                        form.vals({"Email_Opt_in__c":"true"});    
                        form.vals({"ePCNews":"Yes"});
                        form.vals({"ePCEvents":"Yes"});
                        form.vals({"ePCContent":"Yes"});
                    } else {
                        //no topics are checked, and no types are checked, so opt-out
                        form.vals({"Unsubscribed":"true"});
                        form.vals({"Email_Opt_in__c":"false"});    
                        form.vals({"ePCNews":"No"});
                        form.vals({"ePCEvents":"No"});
                        form.vals({"ePCContent":"No"});
                        form.vals({"ePCLogistics":"No"});
                        form.vals({"ePCProduction":"No"});
                        form.vals({"ePCSCPO":"No"});
                        form.vals({"ePCSOP":"No"});
                        form.vals({"ePCWorkforce":"No"});
                    }
                }
            }        
            var valszz = form.vals();
            //alert("Submitted values: " + JSON.stringify(valszz));
        });
    });
</script>

 

Darshil or @SanfordWhiteman, is there a specific javascript we can use to automate this directly on the landing page? And would this JS need to be applied to the landing page or in the form's CSS?

 

Thank you,

LK 

Michael_Florin
Level 10

Re: Can I show options on email preferences form based on boolean fields?

Have you checked if form pre-fill works on any other field? I'm asking as there was an issue which affected the Ashburn, London and San Jose data centers a couple weeks ago. It might be fixed by now, but you should update your form and drag it back in onto your landing page.

 

Michael_Florin_0-1686123353402.png