Using multiple form conditions to determine thank you page - GDPR | Community
Skip to main content
Tyria_Saul
New Participant
March 26, 2018
Solved

Using multiple form conditions to determine thank you page - GDPR

  • March 26, 2018
  • 1 reply
  • 7705 views

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.

Best answer by SanfordWhiteman

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.

1 reply

SanfordWhiteman
New Participant
March 26, 2018

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
New Participant
March 26, 2018

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

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
March 26, 2018

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.