SOLVED

Prefil email field using url parameter

Go to solution
Anonymous
Not applicable

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
SanfordWhiteman
Level 10 - Community Moderator

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
John_Clark1
Level 10

It's also possible that your CC staff could unsubscribe leads themselves.  You'd just want to be sure that munchkin was removed from the page so their browsers didn't get cookied as the lead's themselves.  You can find instructions for that below.

How to remove Munchkin from landing pages

John

Anonymous
Not applicable

Thanks john, but we want to leave it up to the customer to confirm the correct email address to unsubscribe, not the CC staff.

SanfordWhiteman
Level 10 - Community Moderator

You need to remove the _mkto_trk cookie / _mkt_trk field from the form as well, not just remove Munchkin (because staff will already have a Munchin cookie).

Neil_Robertson6
Level 5

That is the way to do it but I would, if possible, see if you can encrypt/decrypt the string and not pass emails in the URL as plain text - otherwise your database could be open for rogue unsubscribes.

SanfordWhiteman
Level 10 - Community Moderator

Unless you mean leaving it encrypted all the way to the back end (necessitating a custom, very complex back-end workflow that I don't know that anybody is actually doing in reality) then you can already post the form on behalf of whomever you choose.

SanfordWhiteman
Level 10 - Community Moderator

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).

Anonymous
Not applicable

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?

SanfordWhiteman
Level 10 - Community Moderator

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

Lucho_Soto
Level 5

Will an email token work if used as the default value? We're also looking at an example where most traffic won't have parameters but we want to keep the email field hidden.

I wasn't able to get this to work on an external landing page, but am wondering if this would work on a Marketo landing page.

SanfordWhiteman
Level 10 - Community Moderator

Not sure exactly what you're asking...

  • A {{lead.token}} can't be used on an non-Marketo LP.
  • On a Marketo-hosted LP, if you want the Email Address field to be hidden, just set the type to Hidden, enable Pre-Fill, and also enable Auto-Fill from a URL param with the default value {{lead.Email Address}}. The URL param will take precedence, if non-empty (i.e. an empty but present URL param, like ?email=&utm_campaign=blah... will not set the value to empty but will use the existing lead value).
Dan_Stevens_
Level 10 - Champion Alumni

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>

.

SanfordWhiteman
Level 10 - Community Moderator

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

Ed_Wong
Level 2

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

SanfordWhiteman
Level 10 - Community Moderator

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
Ed_Wong
Level 2

Nice! Got it to work. Thank you, again!

For others, i added a new Rich Text field in the form containing nothing but <span id="showEmail"></span>

save & approved the form

re-save & approved landing page

Dan_Stevens_
Level 10 - Champion Alumni

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:

Anonymous
Not applicable

Fabulous, thank you so much.