SOLVED

Re: Pre-populate form via embed code on Marketo page

Go to solution
Anonymous
Not applicable

Pre-populate form via embed code on Marketo page

Hello,

I am trying to find a solution for an issue I am having.

I am using the same contact form on multiple Marketo landing pages and use the embed code instead of the drag and drop form. I am doing this because I need to use the Forms 2.0 JS to control a few of the forms fields and follow-up pages. 

The issue I am having is the form does not pre-populate when using the embed code even though its on a Marketo landing page. if I drag a form on the landing page instead of using the html it pre-populates correclty.

Any help would be very appriceated.

-Anthony
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Veronica_Holme4
Level 10 - Champion Alumni

Re: Pre-populate form via embed code on Marketo page

Hi - I'm not sure I fully understand your rationale for using the embed versus the drag and drop form. You can still use additional JS code on the landing page to control field/form functions if you use the drag and drop method - you put the javascript into the landing page using the HTML box that you can drag and drop onto the landing page.

Can you give us some more detail on what you are trying to do?

This is expected behaviour and there's no workaround for it - the embed code simply won't pre-populate data right now. We need to think of a way so you don't have to embed the form.

View solution in original post

7 REPLIES 7
Veronica_Holme4
Level 10 - Champion Alumni

Re: Pre-populate form via embed code on Marketo page

Hi - I'm not sure I fully understand your rationale for using the embed versus the drag and drop form. You can still use additional JS code on the landing page to control field/form functions if you use the drag and drop method - you put the javascript into the landing page using the HTML box that you can drag and drop onto the landing page.

Can you give us some more detail on what you are trying to do?

This is expected behaviour and there's no workaround for it - the embed code simply won't pre-populate data right now. We need to think of a way so you don't have to embed the form.
Matt_Stone2
Level 9

Re: Pre-populate form via embed code on Marketo page

Veronica is correct -- it won't prepopulate in embed mode, regardless of where it lives.

Personally, I've done this a few times (embedded a 2.0 form on a Marketo landing page), because it gives me greater control over the template. I'm not a fan of the absolute positioning system, though my method also has its disadvantages due to the lack of prepopulation and if javascript is disabled, there's no fall-back.
Anonymous
Not applicable

Re: Pre-populate form via embed code on Marketo page

Here is additional details.

I am trying to change the follow-up page of the form via JS, and set a hidden fields value via JS. the only way i know how to do this is via the embed code. I know if I use the drag and drop method I no longer need to change the follow-up page as it can be done in the form itself. however I do not know how to set a specific field. 

Here is my embed code I am using. If anyone could help me maniplulate the form via JS when I drag and drop that would be very helpful. 

<script src="//app-sjg.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_3234"></form>
<script>MktoForms2.loadForm("//app-sjg.marketo.com", "999-999-999", 3234, function(form){
 
form.onSuccess(function(values, followUpUrl){
    //Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl.
    location.href = "my URL goes here";
    //return false to prevent the submission handler continuing with its own processing
    return false;
  });
 
//Set the value of the form source field
form.setValues({ "Form_Source__c":"test"});
 
});
</script>
Matt_Stone2
Level 9

Re: Pre-populate form via embed code on Marketo page

Per what Veronica said, you can probably use the drag and drop method to add the form, then add an HTML element below the form and drop in your javascript. Have you tried that?
Anonymous
Not applicable

Re: Pre-populate form via embed code on Marketo page

I have tried that and it adds a second form. I am unsure how to just modify the form and not add a second form. 
Matt_Stone2
Level 9

Re: Pre-populate form via embed code on Marketo page

Just drop in this part:

<script>MktoForms2.loadForm("//app-sjg.marketo.com", "999-999-999", 3234, function(form){
 
form.onSuccess(function(values, followUpUrl){
    //Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl.
    location.href = "my URL goes here";
    //return false to prevent the submission handler continuing with its own processing
    return false;
  });
 
//Set the value of the form source field
form.setValues({ "Form_Source__c":"test"});
 
});
</script>
Anonymous
Not applicable

Re: Pre-populate form via embed code on Marketo page

I have done that and it still puts a second form at the bottom of the page. 

http://info.equinix.com/14Q2-Cross-Vertical-MYM-Nurture-NA-USContact-Me_testtest.html