Re: AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo

Romina
Level 2

AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo

Hello all. We are looking to create a lenghty form to place on our AEM website. As we don't want to create additional Marketo fields, we are thinking of using AEM forms instead and have the submissions feed into Marketo. But we are not sure if we can do a many-to-one mapping. We would like most fields to map to only one field in Marketo (including the questions).

For example, we would have the following questions on the AEM form:
Q1: What is you favorite color?
A: Blue
B: Red

Q2: What is your favorite season?
A: Summer
B: Spring

If I fill in the form and I choose for Q1 answer A and for Q2 answer B, the information would be passed to only one field as follows:
What is you favorite color? Blue
What is your favorite season? Spring

Has anyone does this before? And if yes, please share any advice you may have.

Thanks All, hope you have a great day ahead!

Tags (2)
12 REPLIES 12
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo

Well, since this is not a Marketo form you'd most likely be making Marketo form submissions in the background to register the form fill activity and send data to Marketo (you can use the submitForm API endpoint too, but background form submission using the form2 API is more robust due to multiple reasons). While making the form submit, you can set the value in the Marketo fields as per your requirement, e.g., concatenate multiple questions and their responses. It's just that the field should be able to accept that data in Marketo, e.g., the type should match (you would want an open text/string field most likely) and if the field to which you're writing data is a CRM synced picklist field, you may run into sync errors in case the value you have in the field isn't one of the available picklist values, so you may want to account for that. Additionally, goes without saying, but if this field's values are being referenced anywhere in campaigns, flow, etc., you'd have to account for the way you'd store data in it there as well.

 

Romina
Level 2

Re: AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo

Thank you for your advice, @Darshil_Shah1 . I had a look at Marketo form submissions in the background and from what I am understanding this form will be placed on the same website page as the AEM form and capture the submissions "in parallel"?
How would this hidden form then be linked to the actual AEM form so that the information submitted is passed from one system to the other? Would you happen to know? Any resource you could share would be appreciated. Thank you!

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo


@Romina wrote:

Thank you for your advice, @Darshil_Shah1 . I had a look at Marketo form submissions in the background and from what I am understanding this form will be placed on the same website page as the AEM form and capture the submissions "in parallel"?


Yes, this form would be placed on the same webpage where you've your AEM form.



How would this hidden form then be linked to the actual AEM form so that the information submitted is passed from one system to the other? Would you happen to know? Any resource you could share would be appreciated. Thank you!

Well, forms aren't technically linked. The background form submission method picks the data submitted by the visitor for each field on a non-Marketo form (in your case an AEM form), adds the respective field's data to a hidden field in the Marketo form, and makes a form submission post to Marketo. This method allows you to pass the form-fill data and activity in Marketo so you can seamlessly reference data and reference the form-fill activity in the triggers/filters in your campaigns/smart lists.

Romina
Level 2

Re: AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo

Thank you @Darshil_Shah1 , makes sense. I do have a few more questions please.

From what I am seeing in the article, two codes must be used for the information be passed from AEM to Marketo. The blank form code (i.e. <form id="mktoForm_1068" style="display:none"></form>) that must be placed on the AEM webpage, but there is a second code with the mapping. Where does that go? Or is it just me creating hidden fields in the form? The article doesn't state. 

Secondly, how would I insert the above scenario (mapping multiple fields to one) into the code? Would it be something like this?

var myForm = MktoForms2.allForms()[0];
myForm.addHiddenFields({
//These are the values which will be submitted to Marketo
"Email":"test@example.com",
"FirstName":"John",
"LastName":"Doe"
"PersonNotes":"What is you favorite color?":Blue","What is your favorite season?":Spring"
});
myForm.submit();

And how would I ensure the questions are also passed into Marketo? Is that possible at all? What we want is to have in Person Notes exactly this "What is you favorite color?":Blue","What is your favorite season?":Spring" etc.

Thank you again for your help.

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo

The first piece is just the <form> tag that basically creates a space on the HTML document for the form to live (of course, here the form would not be displayed). However, the second piece of code is Marketo Forms JS code that uses the Marketo form method addHiddenFields(values) to add the reqd. hidden fields dynamically on the fly as the background form itself is created w/o any fields in the Marketo form editor. The hidden fields you add to the form correspond to the Marketo fields in which you want to store the data submitted in the AEM form fields. Both the <form> tag and Marketo form JS go on the client side on the webpage. 

var myForm = MktoForms2.allForms()[0];
myForm.addHiddenFields({
//These are the values which will be submitted to Marketo
"Email":"test@example.com",
"FirstName":"John",
"LastName":"Doe",
"FavoriteColor":"Blue",
"FavoriteSeason":"Spring" 
});
myForm.submit();

You can have separate fields in Marketo to store each attribute like in the above script. Please note that the fields you add in the above script in the addHiddenFields() should already exist as custom/standard fields in Marketo. Forms 2.0 API uses SOAP API names of the fields, so make sure you use those in the script. Alternatively, if you don't want to create additional custom fields and want to keep it as generic as possible, then you can pass the form questions and responses coalesced in JSON/CSV format and post it to a single field (like Person Notes).

var myForm = MktoForms2.allForms()[0];
myForm.addHiddenFields({
//These are the values which will be submitted to Marketo
"Email":"test@example.com",
"FirstName":"John",
"LastName":"Doe",
"PersonNotes":"{'What is you favorite color?':'Blue','What is your favorite season?':'Spring'}"
});
myForm.submit();
Romina
Level 2

Re: AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo

@Darshil_Shah1 thank you for the thorough explanation. The second code will probably work better for us. I will populate it accordingly and give to our web specialist to add it to the form page. But I do have a quick question - how would Marketo process the JSON? Thank you.

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo


how would Marketo process the JSON? Thank you.

Great question! Marketo would save this JSON string as-is in the Person Notes field (i.e., exactly the way you submit in the field during the form POST). Of course, you can use the Velocity script to convert this valid JSON string to the parseable Velocity map literal and add data to your emails (if need be). Check out this post by Sandy, it has all the details you'd need on using Marketo JSON fields in Velocity (and beyond).

Romina
Level 2

Re: AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo

Thank you @Darshil_Shah1. Will have a look.

Michael_Florin
Level 10

Re: AEM forms to Marketo forms - is it possible to map multiple AEM form fields to one in Marketo

Just a side note: Have you considered _not_ using AEM forms at all, but embedded Marketo forms instead?

 

Here's where I'm coming from: Who's owning forms? Web or automation? My answer would be automation, as the backend processing of the form submit is much more interesting for the business than the customer facing frontend. 

 

If you used Marketo forms, you have more control over fields, dynamic field visibility, form-prefill, progressive profiling and the like. Just hand over your form embed code - or just your form ID - to the web folks, and then do the rest yourself. IMHO this is the superior approach to forms.