Form pre-fill for Marketo forms not hosted on Marketo landing pages

Anonymous
Not applicable

I just learned that pre-fill isn't available for Marketo forms not hosted in Marketo landing pages. 

Does anyone know a custom way to make Marketo forms auto-fill when hosted on WordPress? Hoping there's a JavaScript trick or something but could be wishful thinking. 

Thanks,

David

Tags (1)
26 REPLIES 26
Anonymous
Not applicable
For one customer, I did use jquery code on the external form communicate with custom pho using REST API on the server using JSON objects. 

Rajesh

Kenny_Elkington
Marketo Employee
I'm currently working on putting a blog post together on using REST to implement external page prefill.  I'll try to have it up sometime next week.

That said, Jep is not correct regarding prefill with iframes, this solution still functions with forms 2.0, though forms 2 has more sophisticated styling, and collapses the two label and input columns into one when the viewport is less than 480px, so the styling is less predictable.

P.S. Assuming we're using wordpress or another PHP based solution, would people prefer a simple curl-based method, or something based on a REST framework like guzzle?

Thanks,
Kenny
Aida_Kamber
Level 2

Have you been able to put a blog post together on using REST to implement external page prefill?

Thanks - Aida

Kenny_Elkington
Marketo Employee
Nevin_Laughlin
Level 1

Can you add an example to the blog post that shows calling the endpoint with javascript?

I have tried using jQuery and I get a "No Access Control Origin" when asking for json, and if I try with jsonp I get this error 'Uncaught SyntaxError: Unexpected token :' in the response.

Thanks!!

SanfordWhiteman
Level 10 - Community Moderator

You must not call the REST API directly from the client side. That's even worse than the DoS vulnerability that you create by using the API at all.

Dan_Stevens_
Level 10 - Champion Alumni

Sounds like Kenny Elkington​ should update the blog to ensure users are aware of the risks involved - especially as I'm seeing more and more references to this blog post due to the increased need to use pre-fill on non-Marketo LPs.  Or better yet, update it with a more secure approach.  Just curious, the API call needs to be made for anyone that visits the form page, correct - since there's no way to determine whether or not a lead is KNOWN without doing so.  And then if the call returns values (or doesn't return an error), we know the lead is KNOWN.  Correct?

SanfordWhiteman
Level 10 - Community Moderator

I would love it if the landscape of supported/suggested technologies could change.

There's a scalable, secure, reliable, yet not officially supported way to accomplish this.  Unfortunately, I doubt I could get Marketo proper to agree that this is the way so I don't describe it here. It would appear to be a hack (I call it elegant!) compared to the seemingly intuitive API method, but the problem is the API method really isn't ready for prime time.

And yep, the first reason (though not the only one) that the API-based solution is such a tasty invitation for a DoS attack is that you're expending API calls even when the lead is anonymous. To avoid this, you can use hidden form with Known Lead HTML enabled to determine if the lead is known (or you could call an undocumented endpoint directly, but I won't advise that here). But honestly that just improves the scalability for non-malicious situations.  Once someone is trying to hack you this won't make a difference.

Nevin_Laughlin
Level 1

Thanks a lot for you response.

Anonymous
Not applicable
@Jep are you saying that the pre-fill feature will not work if you put a forms 2.0 in an iframe? I am trying to solve this same issue where I want to embed a MKTO LP with a form2.0 on our own web page, and not sacrifice the form pre-fill function.
Anonymous
Not applicable
Sounds like a wonderful post for Murtza Manzur and the developmenet community. This should really be created. 
Jep_Castelein2
Level 10
Timothy, it's not a standard feature so there is no documentation. One of of our customers implemented this, back then using the SOAP API. Since we now have a REST API, that is a little faster for read-access, so I would recommend using that. 
Anonymous
Not applicable
@Jep. How would we go about doing that Marketo REST API call? Can you point to any documentation?
Aida_Kamber
Level 2

I was able to find some documentation here: http://developers.marketo.com/blog/external-page-prefill/

However, we are still having issues and getting errors when testing this using Rest API.

Here is the info our developer has sent me outlining the issues. Can anyone help?

As per above link to prefill in external non marketo , we need to first authenticate with marketo and after that we can access the data from marketo. When we tried to access rest api for authentication, we received an error due to cross domain (here is the error message XMLHttpRequest cannot load https://007-aqx-577.mktorest.com/identity/oauth/token?grant_type=client_cre…3b4e-4f3d-aaca-1251c1323.... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://jord.webstarts.com' is therefore not allowed access.)

Below is code snippet:-

<script>
alert('testentryfunction');
var url = "https://007-AQX-577.mktorest.com/identity/oauth/token?grant_type=client_credentials&client_id=300e44...";
var client = new XMLHttpRequest();
client.open("GET", url, false);
client.responseType = "application/json";
client.setRequestHeader("Content-Type", "application/json");
client.setRequestHeader("Access-Control-Allow-Origin", "*");
client.send();
alert('testexistfunction');
</script>

We tried accessing the same url with chrome poster and it's working fine, but when we are adding it into a site exposed over the Internet for testing, we are getting an error. This call is going through a browser and I think we can’t use these API’s directly from a browser. If this is true then do we need to first call rest API from .Net, get data and then pre-populate on form when it's loaded?

SanfordWhiteman
Level 10 - Community Moderator

Correct. You must not use the APIs from a browser because you would be exposing your secret key to the world.

So the way to do this is by using .NET as a proxy to call the REST API securely and return results.

Or fly up to NYC for my talk at the August MUG meeting and learn how to do it all in the browser without any security leaks.

Aida_Kamber
Level 2

Thanks Sanford! OR you can come to ATL and present this solution in our MUG meeting

SanfordWhiteman
Level 10 - Community Moderator

Let's see how it goes up here first!

Anonymous
Not applicable

Where do i sign up for this MUG meeting?

Kenny_Elkington
Marketo Employee

You can find the User Group list here.

Anonymous
Not applicable
Thanks Jep. In our case, we have SPARK edition. So, we don't have access to the Marketo API. Any information out there on how to sync the Marketo leads to Wordpress? Just trying to gauge how many development hours would be required. Sounds like this may be quite a task.