We had a company do a custom implementation to make Marketo forms embedded onto our website (i.e. not on marketo landing pages), have their fields prefill if the Marketo cookie info exists. On my first read through of Marketo's announcement that they are changing how it will work , I'm pretty sure our custom work will stop working and prefill will no longer happen (which stinks), but I'm trying to confirm it one way or the other.
I'm hoping someone can read through the info below and confirm 100% either way whether our implementation will stop working. It may not be enough information but hopefully it is...
The company who did the work said they would do it this way:
- Include an endpoint that reroutes REST calls to the Marketo API, keeping the ClientId and ClientSecret hidden from the client-side
- Finish the implementation from the client-side as per the documentation, but instead making the REST call to the local server instead of the Marketo one, e.g.: www.example.com/services/marketo_leads.ashx?filterType=cookie&filterValues=<cookie>&fields=email,firstName,lastName,company (the &access_token=<token> is appended on the server side)
And the "documentation" they referred to is this below:
ISSUE: Marketo Form Fields on our site are not prefilling with users info. When someone submits a Marketo form and later returns to another page with a Marketo form on it, the fields are NOT prefilled. This makes it annoying for the user to have to re-enter their information if they want to download another gated asset.
SOLUTION: Use REST API to get lead data from Marketo (via stored cookie) and use JS to populate the form fields.We contacted Marketo support and they pointed us to this page:http://developers.marketo.com/blog/external-page-prefill/
NOTE: This git repo has some existing code for Marketo REST calls (including C#), which could be helpful: https://github.com/Marketo/REST-Sample-Code
OVERALL STEPS:There will be two REST calls to Marketo:
- Get a new access token using “client_id” and “client_secret”. Below is the complete URL structure for that (including our specific host URL, our client_id and our client_secret). https://XXX-mtz-XXX.mktorest.com/identity/oauth/token?grant_type=client_credentials&client_id=XXX&client_secret=XXX
- Get lead data using the “_mkto_trk” cookie value and the access token. Below is the URL structure for this call, but obviously need to fill in the corresponding <cookie> and <access_token> values. https://XXX-mtz-XXX.mktorest.com/rest/v1/leads.json?filterType=cookie&filterValues=<cookie>&fields=email,firstName,lastName,company&access_token=<access_token>NOTE: The _mkto_trk cookie value includes an ampersand and needs to be URL encoded to ‘%26’ in order to be properly accepted by the Marketo endpoint.
Once the 2nd REST call returns the lead data, it needs to be printed to the “mktoLead” variable:
Finally, map the lead data into the proper fields of the form