SOLVED

Re: Can you insert field data into forms api submit() function

Go to solution
Justin_Eichelb1
Level 2

Can you insert field data into forms api submit() function

My company's current process is: 

  1. Custom form on website
  2. On Submit, we push the data to our own database
  3. A custom procedure manages the Person create/update, merges the anonymous record, creates a custom activity that mimics a marketo form fill.

We capture the Marketo cookie id (forgive me for not using exact terminology here) in order to merge the anonymous record via the API call.

We have an oppty to update step 3 of the process and I now want to change to simply submit the form data and hopefully the cookie id.

Here is my layman’s layout of the new process.

Assume a simple form with only first name and email fields on it.

.submit(

formID: 1234

marketoCookieID: 123-2345-234,

firstName: JJ,

email:jj@domain.com

)

 

My questions to the community.

  1. Does the Marketo form API work this way? I can’t find any examples or
  2. If no, is there a better method other than HTTP POST?  I’ve done that in the past for a customer.  But I don’t believe you get a response. 
  3. How can we merge the anonymous record in this process?
2 ACCEPTED SOLUTIONS

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Can you insert field data into forms api submit() function

 

<form id="mktoForm_789" style="display:none;">
<script src="//pages.example.com/js/forms2/js/forms2.min.js"></script>
<script>
  MktoForms2.loadForm( "//pages.example.com", "123-ABC-456", 789 );
  MktoForms2.whenReady( function(form) {
    form.addHiddenFields({
      Email : "user@example.net"
    });
  });
});
</script>

 

The object passed to addHiddenFields uses the form field names, which are the same as the SOAP names.

 

View solution in original post

Justin_Eichelb1
Level 2

Re: Can you insert field data into forms api submit() function

Thanks Sanford, 

 

So, if I repeat it back to you....

 

Given that this process is happening downstream from the website page being submitted, 

the 'post-form submit procedure' will gather the data from our database, then

inside a php file, we will create a form, adding the data back into hidden fields, then

automatically submitting the form.

 

If i'm correct, then i only have one more question.  Can i pass the anonymous munchkin person id in the form as a data field and will marketo handle the merge?  or will i have to do that in another process once i get a success response with the person id?

 

BTW, if you haven't been told recently, you are appreciated in the Marketo Community.

 

View solution in original post

8 REPLIES 8
SanfordWhiteman
Level 10 - Community Moderator

Re: Can you insert field data into forms api submit() function

 

<form id="mktoForm_789" style="display:none;">
<script src="//pages.example.com/js/forms2/js/forms2.min.js"></script>
<script>
  MktoForms2.loadForm( "//pages.example.com", "123-ABC-456", 789 );
  MktoForms2.whenReady( function(form) {
    form.addHiddenFields({
      Email : "user@example.net"
    });
  });
});
</script>

 

The object passed to addHiddenFields uses the form field names, which are the same as the SOAP names.

 

Justin_Eichelb1
Level 2

Re: Can you insert field data into forms api submit() function

Thanks Sanford, 

 

So, if I repeat it back to you....

 

Given that this process is happening downstream from the website page being submitted, 

the 'post-form submit procedure' will gather the data from our database, then

inside a php file, we will create a form, adding the data back into hidden fields, then

automatically submitting the form.

 

If i'm correct, then i only have one more question.  Can i pass the anonymous munchkin person id in the form as a data field and will marketo handle the merge?  or will i have to do that in another process once i get a success response with the person id?

 

BTW, if you haven't been told recently, you are appreciated in the Marketo Community.

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Can you insert field data into forms api submit() function


Given that this process is happening downstream from the website page being submitted, 

the 'post-form submit procedure' will gather the data from our database, then

inside a php file, we will create a form, adding the data back into hidden fields, then

automatically submitting the form.


That would work, yes. And it automatically includes the cookie. You don't need to do anything special.

 

BTW, if you haven't been told recently, you are appreciated in the Marketo Community.


Thanks!

nmoore
Level 2

Re: Can you insert field data into forms api submit() function

Hi @SanfordWhiteman,

 

Just curious , how does the form.addHiddenFields() method prevent anyone from creating and injecting data into the form?

form.addHiddenFields({"foo:": "bar", "some_key": "some_value"})

 

Are the form fields white-labeled in Marketo somehow? Or is there something about the form submission process that prevents this? Forgive me, I'm not great with JS and web security yet but have a client that is concerned with it and would like to give an educated answer. Thank you

 

nmoore
Level 2

Re: Can you insert field data into forms api submit() function

I think I answered my own question - data can only be submitted through form fields that exist in the Marketo fields list.

SanfordWhiteman
Level 10 - Community Moderator

Re: Can you insert field data into forms api submit() function

Well yes. You can't create brand-new fields in the DB. But you sure can update any fields that aren't blocked from updating, and set fields for the first time.
nmoore
Level 2

Re: Can you insert field data into forms api submit() function

Thanks @SanfordWhiteman. Could you elaborate on what it means to 'set fields for the first time'?

SanfordWhiteman
Level 10 - Community Moderator

Re: Can you insert field data into forms api submit() function

When they go from empty to non-empty.