I'm trying to pre-populate the hidden fields on my Smart Capture form from a CloudPage URL to gather survey responses. Here's what I've done so far:

I have an email I want to send to data extension "Test Extension". Extension has these fields:

  • Contact ID (primary key, relates to subscribers on subscriber key)
  • Email
  • First Name
  • Last Name

I want to use the Smart Capture form to transfer this data over to extension "Survey Results" and fill out two extra fields there, Rating and Comments.

My email contains a link to a CloudPage URL (Page ID 123) that should pass subscriber info through an encrypted query string to pre-populate hidden attributes on my Smart Capture form. Here is what I have to generate that URL:

<a href="%%=RedirectTo(CloudPagesURL(123, 'Contact ID', @contactid, 'First Name', @firstname, 'Last Name', @lastname, 'Email', @emailaddr))=%%">

Next, I placed this AMPscript in an HTML block at the top of my email:


Set @contactid = [Contact ID]
Set @firstname = [First Name]
Set @lastname = [Last Name]
Set @emailaddr = Email
var @firstname, @lastname, @emailaddr
set @firstname = Lookup("Test Extension", "First Name", "Contact ID", @contactid)
set @lastname = Lookup("Test Extension", "Last Name", "Contact ID", @contactid)
set @emailaddr = Lookup("Test Extension", "Email", "Contact ID", @contactid)
set @contactid = Lookup("Test Extension", "Contact ID", "Contact ID", @contactid)


Lastly, I set the value of the hidden attributes in my Smart Capture form on my CloudPage like this example:

%%[SET@contactid=QueryParameter('Contact ID')]%%

I sent the email to myself as a contact in Test Extension and clicked the link. The link goes to my page with the Smart Capture form, and I submitted the form with success. But when I go to the target data extension "Survey Responses," a record has been created with values only in the two visible fields I filled out (Rating and Comments). There's nothing in Email or First or Last Name, and the Contact ID has value of 0. Can you tell where I'm going wrong?

1 Answer 1


In order to be populated, the value of your hidden field needs to be the value of the variable- You might be confusing it with the SET statement of a variable:

assuming this code is above your hidden field:

set @contactid = Lookup("Test Extension", "Contact ID", "Contact ID", @contactid)

, this is how you would enter the value into the hidden field:

<input id="contactIdField" name="contactIdField" type="hidden" value="%%=v(@contactId)=%%">

As a general note, always be cautious with prefilling forms from emails, as emails can be forwarded and thus personalized links can get into wrong hands, encrypted or not. This would surface PII. Just go through your due diligence before going to production.

  • That solved it, thank you! When this form is submitted, is that PII transmitted or an encrypted hash that ties the info back to its record? Is it an option to have just one encrypted field to tie the info back to the extension? So for instance, the URL would have the random key, and that ensures new info ties back to the subscriber's email or ID in the extension, so when that data is received, that key populates the rest of that info and ties it to that subscriber?
    – kimchi
    Commented Sep 25, 2020 at 21:45
  • ContactId alone should be pseudonymous, so it kind of fills the role of what you are looking for. (which is one of the many reasons why email is such a bad choice for ContactId). I was just trying to indicate that a prepopulated email, firstname, lastname etc. on a form are PII, so surfacing those always leaves a bit of a bad taste if senders and/or recipients are unaware that "normal" email forwarding potentially compromises that. Commented Sep 25, 2020 at 22:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .