SOLVED

Using multiple form conditions to determine thank you page - GDPR

Go to solution
Tyria_Saul
Level 2

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
SanfordWhiteman
Level 10 - Community Moderator

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
Anonymous
Not applicable

For the record this is up and running now small issue on the word press side of things.  Thanks Sanford.

Dan_Stevens_
Level 10 - Champion Alumni

Looks like you don't have permission to edit forms.  You'll need to ask the admin who manages your Marketo instance.

Anonymous
Not applicable

pastedImage_0.pngbut I was made an admin a few months ago, does that not include all parts of the application?

Tyria_Saul
Level 2

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>
SanfordWhiteman
Level 10 - Community Moderator

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

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

Grégoire_Miche2
Level 10

Hi Tyria,

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

-Greg

Tyria_Saul
Level 2