SOLVED

Prefil email field using url parameter

Go to solution
Highlighted
Anonymous
Not applicable

Prefil email field using url parameter

We have a scenario where customers will phone or email our Contact Centre directly and ask to be unsubscribed. Our CC staff do not have access to Marketo and we do not have a CRM to manage this.  They have asked that:

  1. When a customer contacts us directly, our CC staff will provide that customer with a URL
  2. The URL will be a Marketo (unsubscribe) landing page, with the email address prefilled.
  3. The customer will then go to that landing page, with their email address prefilled, and confirm they wish to be unsubscribed by clicking on the unsubscribe button.

My question is, without access to Marketo, is there a way for our CC staff to generate a URL of the unsubscribe landing page, that allows email address prefil?  Something that would simply require them to just update the email address in the URL each time?

TIA

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Level 10 - Community Moderator

Re: Prefil email field using url parameter

Sure. An easy approach is by having a regular Rich Text widget in addition to the hidden text field.  Copy the value into the widget so you can style it however you want.

Just takes a little line of JS:

MktoForms2.whenReady(function(form){

  form.getFormElem()[0].querySelector('#showEmail').innerHTML = form.getValues().Email;

})

Demo here: http://pages.vaneck.com/simple-unsubscribe.html?Email=chantell@tapsell.com

View solution in original post

17 REPLIES 17
Highlighted
Level 10 - Community Moderator

Re: Prefil email field using url parameter

Sure, it's very easy. In Form Editor, set the Email field to pull its value from the URL param "email." To set this up, use the Hidden field type. Then you could unhide it using JS if you want, or just read the value out and put it somewhere else on the page (form.getValues().Email).

Highlighted
Anonymous
Not applicable

Re: Prefil email field using url parameter

Thanks Sanford.  I can easily set the Form Editor to pull the URL param for it's value.  But ideally i still want that field to be visible for the customer, as we want the customer to view their email address and confirm that is the one they wish to unsubscribe.

is there a way for the field to still be visible and also accept URL param?

Highlighted
Level 10 - Community Moderator

Re: Prefil email field using url parameter

Sure. An easy approach is by having a regular Rich Text widget in addition to the hidden text field.  Copy the value into the widget so you can style it however you want.

Just takes a little line of JS:

MktoForms2.whenReady(function(form){

  form.getFormElem()[0].querySelector('#showEmail').innerHTML = form.getValues().Email;

})

Demo here: http://pages.vaneck.com/simple-unsubscribe.html?Email=chantell@tapsell.com

View solution in original post

Highlighted
Anonymous
Not applicable

Re: Prefil email field using url parameter

Fabulous, thank you so much.

Highlighted
Level 10 - Champion Alumni

Re: Prefil email field using url parameter

Sanford Whiteman​, is this code entered inline where the value should be placed within the HTML?  For example, did you enter this as follows:

You're managing subscriptions for

<srcript>MktoForms2.whenReady(function(form){

  form.getFormElem()[0].querySelector('#showEmail').innerHTML = form.getValues().Email;

})

</script>

.

Highlighted
Level 10 - Community Moderator

Re: Prefil email field using url parameter

No, you can put the script anywhere. '#showEmail' refers to a SPAN with id="showEmail" that you insert to hold the value.

Highlighted
Level 10 - Champion Alumni

Re: Prefil email field using url parameter

Still no luck.  Here's what I have in the HTML snippet on the landing page:

<script type="text/javascript">

MktoForms2.whenReady(function(form){

  form.getFormElem()[0].querySelector('#showEmail').innerHTML = form.getValues().Email;

})

</script>

And here's the rich-text:

Please confirm your approval for <span id="showEmail"> </span> to attend the event:

Highlighted
Level 2

Re: Prefil email field using url parameter

hey Sanford,

I was also trying to get this to work with no success. I added the Code above to the Form's reich text editor and it seemed to get commented out with // [CDATA each time i saved.

However i was able to use the HTML widget in the unsub landing page level and it was appearing in the source code of the page. But it still does not reveal the email value with passed on the URL param thru the hidden field. I think it may have something to do with the span id you described above. Can you elaborate if I need to add a span somewhere and where to add it?

Here is my Landing page: Quora for Business - Unsubscribe

Highlighted
Level 10 - Community Moderator

Re: Prefil email field using url parameter

I was also trying to get this to work with no success. I added the Code above to the Form's reich text editor and it seemed to get commented out with // [CDATA each time i saved.

That's actually fine, it's not commenting out all the code. Marketo still inserts the ancient CDATA wrapper even though it's not needed in any modern browser.

The key here is you need

  • a <span> with a known, findable id
  • the Email value somewhere on the form, could be in a Hidden field but it has to be there