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.
Solved! Go to Solution.
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.
You have to either
Thanks Sanford! How would I do option 1? I'm just learning the coding piece so I'm not as familiar.
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.
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>
Hi Tyria,
please provide the URL of your landing page containing the JS code.
-Greg
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.
Thank you I was tweaking some of the fields after I sent it in to see if I could try some other options.
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?