Re: Prefill by user submitted ID

Anonymous
Not applicable

Prefill by user submitted ID

Maybe I missed this somewhere but I want a user to be able to enter their lead ID (it will be mailed to them as an 'activation code') and then when they submit I'll have that inserted into the API and prefill the form with their lead data. Does Marketo have that prebuilt into it somewhere?

Basically they receive a direct mail piece with this activation code (their lead ID) and a landing page URL. They go to the page and its basically just a form with a text input and submit button, they enter their code/lead ID and hit enter. Then I have it grab the lead ID that is entered and it directs them to a multi step form and uses the API to prefill all the lead data we have for them, they fill out the rest and submit. If they come back and enter the code/ID again it prefills with all the previously submitted info (presumably by including all the fields in the query, so if we have it it prefills, if we don't its blank).

17 REPLIES 17
SanfordWhiteman
Level 10 - Community Moderator

Re: Prefill by user submitted ID

You want the pURL feature. This is designed for direct mail -- check docs and Community.

There's no need to use any API here (and I'd never expose API calls via a public interface).

Anonymous
Not applicable

Re: Prefill by user submitted ID

This is going to be an embedded form on an external page

SanfordWhiteman
Level 10 - Community Moderator

Re: Prefill by user submitted ID

There's no way to do this reliably solely with an external page.

You can send them to a pURL first, then redirect them to your external page w/their lead data passed in the query string or hash.

Anonymous
Not applicable

Re: Prefill by user submitted ID

So how would we get them to enter their code (lead ID) to prefill the form. We don't want to send each individual their own pURL

SanfordWhiteman
Level 10 - Community Moderator

Re: Prefill by user submitted ID

Send them to a page with a simple form (which you'd have to do in all cases, if you want to concatenate two different pieces you're sending them).

They enter their code and the form posts to the pURL (example.com/purlifiedpage/XYZ123)

The pURL redirects to your site with their info.

Anonymous
Not applicable

Re: Prefill by user submitted ID

Okay so I have a marketo landing page with this script (user submits their marketo unique code and it appends it to the marketo landing page url to get their data)....

<script>

  var destinationRoot = "https://mydomain.com/form-page"; 

  var mktoFields = { 

  "FirstName"      : "{{lead.First Name}}", 

  "LastName"       : "{{lead.Last Name}}",

  "Phone"          : "{{lead.Phone Number}}",

  "Email"          : "{{lead.Email Address}}"

}; 

document.location.href = destinationRoot + '#' + btoa(JSON.stringify(mktoFields)); 

</script>

and then the form page renders the form and has the following....

<script>

MktoForms2.loadForm("//app-XXXX.marketo.com", "XXX-XXX-XXX", XXXX);

MktoForms2.whenReady( function(form) {

var mktoFields = JSON.parse(atob(document.location.hash.substring(1))); 

  form.setValues(mktoFields);

}

);

</script>

But when it redirects back to my form page its only prefilling first and last name. All the following fields remain empty and I don't know why it's breaking after the last name. Is anything obvious to you about what's incorrect?

SanfordWhiteman
Level 10 - Community Moderator

Re: Prefill by user submitted ID

Let's break it down further. What ends up in the JSON object on the pURL-enabled page, before any forwarding or encoding? That has to look as expected for the next step to work.

Anonymous
Not applicable

Re: Prefill by user submitted ID

When i replace the redirect/encoding with a console.log it shows the JSONobject has the data

Screen Shot 2017-11-01 at 1.50.50 PM.png

SanfordWhiteman
Level 10 - Community Moderator

Re: Prefill by user submitted ID

OK, so far so good. Now check the JS object on the destination page, after it's decoded and parsed.