SOLVED

Re: Using multiple form conditions to determine thank you page - GDPR

Go to solution
Tyria_Saul
Level 2

Using multiple form conditions to determine thank you page - GDPR

Hi all,

I'm building our first ever subscription center for GDPR and I'm trying to get my form to send users to different thank you pages based on their choices. For example, they can opt out of email and/or opt out of cookie tracking. If they opt-in to email and opt-out of tracking we need to send them to a certain landing page with the no tracking url on it. If they opt-out of email but opt-into tracking we need to send them to a different thank you page, etc. There are four different thank you pages in total. I can't figure out how to do this in Advanced Thank you. I can set a single condition, like send them to page A if they choose email opt out, but I can't figure out how to send them to page A if they choose email and date opt-out. Any suggestions would be greatly appreciated!

How are others doing this in their subscription centers? By the way I'm using both Marketo landing pages and forms.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Using multiple form conditions to determine thank you page - GDPR

MktoForms2.whenReady(function(form){
  form.onSubmit(function(form){

    var currentValues = form.getValues(),

    fieldsToConsolidate = ["fieldA","fieldB","fieldC"],

    consolidated__c =

      fieldsToConsolidate

        .map(function(field){

          return currentValues[field];

        })

        .join(";");

   form.addHiddenFields({ consolidated__c : consolidated__c });

});

});

Where consolidated__c is the name of your new custom field and fieldA, fieldB, and fieldC are the names you want to put together.

The resulting consolidated__c field will be a semicolon-delimited string (apples;oranges;pumpkins) so needless to say, the values themselves can't contain a semicolon.

View solution in original post

28 REPLIES 28
SanfordWhiteman
Level 10 - Community Moderator

Re: Using multiple form conditions to determine thank you page - GDPR

You have to either

  1. use JavaScript to consolidate their choices into a single field in the onSubmit, and use that value in your Advanced Thank You; or
  2. use JavaScript in the onSuccess to choose the Thank You page based on crunching multiple values (do not use the Form Editor to choose the TY in this case)
Tyria_Saul
Level 2

Re: Using multiple form conditions to determine thank you page - GDPR

Thanks Sanford! How would I do option 1? I'm just learning the coding piece so I'm not as familiar.

SanfordWhiteman
Level 10 - Community Moderator

Re: Using multiple form conditions to determine thank you page - GDPR

MktoForms2.whenReady(function(form){
  form.onSubmit(function(form){

    var currentValues = form.getValues(),

    fieldsToConsolidate = ["fieldA","fieldB","fieldC"],

    consolidated__c =

      fieldsToConsolidate

        .map(function(field){

          return currentValues[field];

        })

        .join(";");

   form.addHiddenFields({ consolidated__c : consolidated__c });

});

});

Where consolidated__c is the name of your new custom field and fieldA, fieldB, and fieldC are the names you want to put together.

The resulting consolidated__c field will be a semicolon-delimited string (apples;oranges;pumpkins) so needless to say, the values themselves can't contain a semicolon.

Tyria_Saul
Level 2

Re: Using multiple form conditions to determine thank you page - GDPR

Unfortunately the code isn't working for me. Do I have something listed incorrectly?

<script>

MktoForms2.whenReady(function(form){
  form.onSubmit(function(form){
    var fieldsToConsolidate = ["doNotTrack","emailOptIn”], 
    AllOptIn_c = 
      fieldsToConsolidate
        .map(function(field){ 
          return currentValues[field]; 
        })
        .join(";");
 
   form.addHiddenFields({ AllOptIn_c : AllOptIn_c });
 });
});
</script>
Grégoire_Miche2
Level 10

Re: Using multiple form conditions to determine thank you page - GDPR

Hi Tyria,

please provide the URL of your landing page containing the JS code.

-Greg

Tyria_Saul
Level 2

Re: Using multiple form conditions to determine thank you page - GDPR

SanfordWhiteman
Level 10 - Community Moderator

Re: Using multiple form conditions to determine thank you page - GDPR

The field

     emailOptIn

doesn't exist on the form.

I also see a field

     operationalConsolidateOptin

which seems awfully similar to what fieldsToConsolidate is used for.

Also, please (always!) be more specific than "not working," comparing expected behavior and what you observe.

Tyria_Saul
Level 2

Re: Using multiple form conditions to determine thank you page - GDPR

Thank you I was tweaking some of the fields after I sent it in to see if I could try some other options.

Anonymous
Not applicable

Re: Using multiple form conditions to determine thank you page - GDPR

Is there a way to do this without using Marketo forms 2.0? I don't believe I have the right bundle to use the 2.0 editor.

for example, can this be done by embedding this code in <script> </script> tags directly on the landing page?