Will our custom prefill code on non-Marketo pages stop working with Marketo's new changes to how prefill works?

Highlighted
Level 1

Will our custom prefill code on non-Marketo pages stop working with Marketo's new changes to how prefill works?

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:

Suggested solution:

  • 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/

We technically could do everything via Javascript but as I’m sure you know, making the REST call via the browser is a no-no because it would expose our “client_id” and “client_secret” to the public. So we need to make the REST calls via the server-sideIn addition to the link above that Marketo pointed us to, this other page explains how to get the cookie info via JS and then make the REST call to get the associated lead datahttp://developers.marketo.com/blog/get-a-visitors-cookie-id-and-then-query-associated-lead-data/

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:

  1. 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
  2. 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.

Use Javascript to read the existing Marketo cookie. This is obviously needed for the 2nd REST call above.

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

Sanford Whiteman

Tags (1)
3 REPLIES 3
Highlighted
Level 10 - Community Moderator

Re: Will our custom prefill code on non-Marketo pages stop working with Marketo's new changes to how prefill works?

That approach, while technically horrifying and subject to an easy DoS attack, will not be specifically affected by the change.

(Just use my Pre-Fill code. It has no server involvement of any kind. And it's completely free for anyone on any site.)

Highlighted
Level 1

Re: Will our custom prefill code on non-Marketo pages stop working with Marketo's new changes to how prefill works?

Hi Sanford,

If you don't mind, could you give me a quick summary as to why it's technically horrifying? I would like to potentially discuss it with the company who did it, especially if there are security risks with how it's been implemented.

Regardless, where can I find your pre-fill code? Not involving the server at all would be ideal, but I didn't think that was feasible, so I'd love to see your solution. And I would probably change our implementation to your solution if it's as simple as it sounds.

Thanks!

Gary

Highlighted

Re: Will our custom prefill code on non-Marketo pages stop working with Marketo's new changes to how prefill works?