SOLVED

Forms 2.0 and Wordpress

Go to solution
Anonymous
Not applicable

Forms 2.0 and Wordpress

What is the best way to embed a form, using the form 2.0, into Wordpress.

When getting embed code, I see script that looks universal and I put this into the Footer.php file of the template. That means that the form support code will load on every page of the site.

src="//app-sji.marketo.com/js/forms2/js/forms2.js"

The trouble is on my pages themselves. The new form embed code requires an empty DOM element (easy enough) and then page-specific script to load the form from Marketo.

The issue is the Wordpress does not allow Script to be included in Page/Post content.

Suggestions? Specific page templates for any page I want a form on? Using a plugin to let script get put into a page/post?

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Forms 2.0 and Wordpress

I figured it out. Here's what I did and it was quite easy.
  1. Added a reference to src="//app-sji.marketo.com/js/forms2/js/forms2.js" in header.php of my template file. This was easier than loading it on each page. It loads as part of the site.
  2. Read the article here and did the following
    • Created a JavaScript file called loadMarketoForm.js and added to a /scripts folder on our site. It has the following code...
function loadMarketoForm(formId){

if (formId) {
    MktoForms2.loadForm("//app-sji.marketo.com", "our org id value", formId);
}

}
 
  • In my Page, it has something like below...
<form id="mktoForm_1017"></form>
<script type="text/javascript" src="/scripts/loadMarketoForm.js"></script>
<script type="text/javascript">
<!--
loadMarketoForm(1017);
//--></script>
 
  • As I create new Pages in Wordpress, if I want to incude a form, I copy the above code and I just change the form number (1017 above) to whatever is in the embed code for any new forms I create.
Works quite well.


View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Re: Forms 2.0 and Wordpress

"The issue is the Wordpress does not allow Script to be included in Page/Post content." << Pretty sure this isn't true. 

http://codex.wordpress.org/Using_Javascript#JavaScript_in_Posts
Anonymous
Not applicable

Re: Forms 2.0 and Wordpress

I figured it out. Here's what I did and it was quite easy.
  1. Added a reference to src="//app-sji.marketo.com/js/forms2/js/forms2.js" in header.php of my template file. This was easier than loading it on each page. It loads as part of the site.
  2. Read the article here and did the following
    • Created a JavaScript file called loadMarketoForm.js and added to a /scripts folder on our site. It has the following code...
function loadMarketoForm(formId){

if (formId) {
    MktoForms2.loadForm("//app-sji.marketo.com", "our org id value", formId);
}

}
 
  • In my Page, it has something like below...
<form id="mktoForm_1017"></form>
<script type="text/javascript" src="/scripts/loadMarketoForm.js"></script>
<script type="text/javascript">
<!--
loadMarketoForm(1017);
//--></script>
 
  • As I create new Pages in Wordpress, if I want to incude a form, I copy the above code and I just change the form number (1017 above) to whatever is in the embed code for any new forms I create.
Works quite well.


Anonymous
Not applicable

Re: Forms 2.0 and Wordpress

So, what I said? 😉
Anonymous
Not applicable

Re: Forms 2.0 and Wordpress

Jason, yes, what you said, but I wanted to document the implementation rather than just a link to read more about how to do it. I figured that is more valuable to the community.
Anonymous
Not applicable

Re: Forms 2.0 and Wordpress

Thanks Scott 🙂 Always love to see more WordPress stuff on here.
Anonymous
Not applicable

Re: Forms 2.0 and Wordpress

Sure thing. I wasn't trying to boost myself with the Best Answer selection either. I just thought the implementation of it should be marked. I honestly don't care about that stuff, but thought others might want to jump right to the answer.
Anonymous
Not applicable

Re: Forms 2.0 and Wordpress

Or if you want an even easier solution, you can use the Marketo-Wordpress integration on Launchpoint

This allows you to convert any Wordpress form into a Marketo form with pre-fill and progessive profiling. All it takes is a some shortcodes:

[mForm] ... your form .... [/mForm]


See it in action at the Marketo Health-checker. Do a health check, then reload the original page.