Passing values from a non-Marketo form to a Marketo form

George_Hoffman
Level 3

Passing values from a non-Marketo form to a Marketo form

We have an Opt-In Monster lightbox pop up form on our website. Once a contact fills this form out (Name, email) they are taken to a Marketo landing page with another form. We would like "Name" and "email" to auto populate in this form based on the Opt-in monster lightbox form submission.

The Opt-in Monster mapping for these Name and Email is om_name and om_email and cannot be changed. How do I get Marketo to recognize these values as Name and email and auto fill them? Do I have to use javascript?

9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator

Re: Passing values from a non-Marketo form to a Marketo form

If those appear in the query string, yes, very easy to move them to standard fields.

But IIRC you can also build your own form HTML within OM, posting directly to Marketo.

George_Hoffman
Level 3

Re: Passing values from a non-Marketo form to a Marketo form

These wont appear in the query string and we have too many forms in OM to build each one in Marketo and customize it in. After discussing with colleagues, it seems the only way to accomplish this efficiently is with Java.

Is there any other possible efficient way to pull these in or do you recommend going with Java?

SanfordWhiteman
Level 10 - Community Moderator

Re: Passing values from a non-Marketo form to a Marketo form

JavaScript, not Java. Very different.

You have to get the values to the page hosting the Marketo form somehow. There's more than one way to do this (adding them to the referrer URL or to the destination URL will both work) but all ways require JS.

Erik_Heldebro2
Level 8

Re: Passing values from a non-Marketo form to a Marketo form

Hi George,

Was actually wondering the same thing a couple weeks ago about Optinmonster but I just found the best solution today when I was setting up an Optin. You can just choose custom HTML and you can actually just put the Marketo form embed code in there from your form's settings which allows you to basically do what you want with Optinmonster.

You do although need to set up your script so that Optinmonster tracks a conversion when the form is submitted. So it's a pretty sweet deal. Here is more information: How to Connect OptinMonster with any Email Service Provider using our Custom HTML Form

Sanford Whiteman​ you mentioned previously that you should use form onSuccess when you want to trigger a function from your Marketo form being submitted, am I correct here?

SanfordWhiteman
Level 10 - Community Moderator

Re: Passing values from a non-Marketo form to a Marketo form

That's right, when logging anything after (successful) form submit use onSuccess.

You return false from onSuccess and only redirect the page when the *other* process has finished (see my various comments on people's misuse of ga.send()).

Erik_Heldebro2
Level 8

Re: Passing values from a non-Marketo form to a Marketo form

Perfect, thanks Sanford. Just wanted make sure I was on the same page

George_Hoffman
Level 3

Re: Passing values from a non-Marketo form to a Marketo form

This is the Javascript we ended up using!

<script>

function getUrlParameter(name) {

  name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');

  var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');

  var results = regex.exec(location.search);

  return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));

};

 

  var values = {}

  var email = getUrlParameter('om_email');

  if(email) {

    values['email'] = email;

  }

  var name = getUrlParameter('om_name');

  if(name) {

    values['name'] = name;

  }

 

  form.setValues(values);

});

  </script>

SanfordWhiteman
Level 10 - Community Moderator

Re: Passing values from a non-Marketo form to a Marketo form

Don't love the regex, but if it gets the job done in this case, ok.

If you're going to take the lead's input as-is, why not just pull them into hidden fields (since hidden fields can natively pull from query params)?

Erik_Heldebro2
Level 8

Re: Passing values from a non-Marketo form to a Marketo form

George,

Why not use Marketo forms embedded as custom html?

It would be a more scalable solution and allow you to use progressive profiling in Optinmonster.

/Erik